Can't add mysql driver to jboss
Asked Answered
N

6

14

Ok this is driving me crazy. Especially because there are already many similar questions out there. But no answer works for me.

I have jboss 7.1.1 on my windows 7 machine (running it from eclipse normally) and want to use mysql.

I did the following:

1 created directory jboss-as-7.1.1.Final\modules\com\mysql\main

2 Files there: module.xml and mysql-connector-java-5.1.26-bin.jar (downloaded from official mysql site)

3 Content of module.xml:

<?xml version="1.0" encoding="UTF-8"?>
<modulexmlns="urn:jboss:module:1.0" name="com.mysql">
  <resourxces>
     <resource-rootpath="mysql-connector-java-5.1.26-bin.jar"/>              
  </resources>
  <dependencies>
     <modulename="javax.api"/>
  </dependencies>
</module>

4 Relevant parts from jboss-as-7.1.1.Final\standalone\configuration\standalone.xml:

<datasource jndi-name="java:jboss/datasources/mysqlDS" pool-name="mysqlDS" enabled="true" jta="true"  use-ccm="true" use-java-context="true">
    <connection-url>jdbc:mysql://192.168.1.1:3306/eAuftrag</connection-url>
    <driver>com.mysql</driver>
    <security>
        <user-name>root</user-name>
        <password>fffff</password>
    </security>
    <timeout>  
        <idle-timeout-minutes>0</idle-timeout-minutes>  
        <query-timeout>600</query-timeout>  
    </timeout>  
    <statement>  
        <prepared-statement-cache-size>100</prepared-statement-cache-size>  
        <share-prepared-statements>true</share-prepared-statements>  
    </statement>  
</datasource>

and:

 <driver name="com.mysql" module="com.mysql" />

Everytime I start the jboss server I see this message:

service jboss.jdbc-driver.com_mysql (missing) dependents: [service jboss.data-source.java:jboss/datasources/mysqlDS]

And when I go to the managment-console and look at datasources, the mysqlDS is listed there, but when I click on it I get the error (sorry can't select the text there, so here comes the image):

error from managment console

Nisbet answered 11/10, 2013 at 13:17 Comment(2)
` <resourxces>` ? is this right?Angular
no it's not, that's a reason why it didn't work ;) see https://mcmap.net/q/834260/-can-39-t-add-mysql-driver-to-jbossPrudi
N
9

So once more I can pay tribute to my stupidity. I did everything right except I had typos in my module.xml file. Notice that in the code above are no blanks (" ") between some words - somehow they got lost. But what's even worse is that apparantly these module-files are not validated by jboss, that's why I never realized it. Anyway here's the correct config without the typos...

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
  <resources>
     <resource-root path="mysql-connector-java-5.1.26-bin.jar"/>              
  </resources>
  <dependencies>
     <module name="javax.api"/>
  </dependencies>
</module>
Nisbet answered 16/10, 2013 at 6:49 Comment(2)
you also had resourxces (with an X) instead of resourcesChurchless
Same thing happened to me. My XML was invalid. Would be really nice if Mr Jboss throws a " NoWayImParsingYouInvalidCrapXMLException" first , not just the sorry.. I cant load your stuff..Everywhere
U
1

You need to give the driver tag a driver class or a data source.

<driver name="com.mysql" module="com.mysql">
    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
Unroof answered 11/10, 2013 at 20:49 Comment(0)
B
1

Make sure you do NOT have a space at the beginning of module.xml file or you will get a:

new missing/unsatisfied dependencies

...error for this driver.

Byline answered 18/4, 2015 at 22:53 Comment(0)
S
0

To make the JDBC driver classes available to the JBoss Application Server, copy the archive mysql-mysql-connector-java-5.1.5-bin.jar from the Connector/J distribution to the lib directory in the default server configuration (assuming that is the server configuration you’re running).

Now create a mysql-ds.xml

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
  <jndi-name>DefaultDS</jndi-name>
  <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
  <driver-class>com.mysql.jdbc.Driver</driver-class>
  <user-name>root</user-name>
  <password>jboss</password>
  <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
  <metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

you can also refer this links https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7

http://docs.jboss.org/jbossas/getting_started/v4/html/db.html

Surculose answered 11/10, 2013 at 13:31 Comment(1)
hmm this doesnt work. also I did everythign according to your first link (which has nothing to do with solution?)Prudi
C
0

Here is my sample module.xml

<module xmlns="urn:jboss:module:1.1" name="com.mysql">

<resources>
    <resource-root path="mysql-connector-java-5.1.6.jar"/>
    <!-- Insert resources here -->
</resources>
<dependencies>
          <module name="javax.api"/>
          <module name="javax.transaction.api"/>
</dependencies>

Below is the Data source configuration in standalone.xml

<datasource jta="true" jndi-name="java:jboss/jdbc/MyDS" pool-name="AppzillonDS"         enabled="true" use-java-context="true">
  <connection-url>jdbc:mysql://192.168.1.98:3306/mydb?zeroDateTimeBehavior=convertToNull</connection-url>
  <driver>mysql</driver>
    <security>
       <user-name>user</user-name>
       <password>password</password>
    </security>
</datasource>

Look at the driver tag in above. drive is just mysql and not the com.mysql. Hope this should help you....

Chatelaine answered 16/10, 2013 at 7:7 Comment(0)
P
0

WILDFLY 10 using mysql 5.7

follow this steps: comment or delete exampleds in standalone.xml

  1. into jboss-cli.bat --connect

after execute command [standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)

should be ok

this modified standalone.xml, then add

<datasources>
<!--
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
    <user-name>sa</user-name>
    <password>sa</password>
</security>
</datasource> -->
<datasource jndi-name="java:/mysql" pool-name="mysqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/wildfly</connection-url>
<driver>mysql</driver>
<security>
    <user-name>root</user-name>
    <password>jdfoxito10</password>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>

should look like!

and module.xml put in

\java\server\wildfly-10.1.0.Final\modules\system\layers\base\com\mysql\main

mysql-connector-java-5.1.40-bin.jar (come installer mysql-installer-community-5.7.15.0.msi) module.xml

and content from module.xml like:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.40-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

and ready, JAVA_HOME should be ok

Parks answered 10/10, 2016 at 1:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.