Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildfly 10 failing to load MySQL XA driver on startup

I have a web application I am deploying in wildfly-10.0.0. It requires a mysql xa driver. I have the following error:

2015-10-13 12:25:37,979 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([ ("subsystem" => "datasources"), ("jdbc-driver" => "com.mysql") ]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.mysql]"

The modules directory is as follows:

 Directory of C:\Users\rball\Documents\Dev\WildFly\wildfly-10.0.0.CR1\modules\sy
stem\layers\base\com\mysql\main

10/13/2015  11:32 AM    <DIR>          .
10/13/2015  11:32 AM    <DIR>          ..
10/13/2015  12:25 PM             1,575 module.xml
03/17/2015  05:21 AM           968,670 mysql-connector-java-5.1.35-bin.jar

The module.xml file is:

   <?xml version="1.0" encoding="UTF-8"?>    

<module xmlns="urn:jboss:module:1.1" name="com.mysql">  
  <resources>  
    <resource-root path="mysql-connector-java-5.1.35-bin.jar"/>  
  </resources>  
  <dependencies>  
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>      
  </dependencies>  
</module>  

I added the driver and datasource to the datasources section of standalone.xml:

<xa-datasource jndi-name="java:/jdbc/MyXaDS" pool-name="MyXaDSPool" enabled="true" use-ccm="false">
                <xa-datasource-property name="URL">
                    jdbc:mysql://localhost:3306/temp?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8
                </xa-datasource-property>
                <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                <driver>com.mysql</driver>
                <xa-pool>
                    <min-pool-size>10</min-pool-size>
                    <max-pool-size>20</max-pool-size>
                    <is-same-rm-override>false</is-same-rm-override>
                    <interleaving>false</interleaving>
                    <pad-xid>false</pad-xid>
                    <wrap-xa-resource>false</wrap-xa-resource>
                </xa-pool>
                <security>
                    <user-name>root</user-name>
                    <password>password</password>
                </security>
                <validation>
                    <validate-on-match>false</validate-on-match>
                    <background-validation>false</background-validation>
                    <background-validation-millis>1000</background-validation-millis>
                </validation>
                <statement>
                    <prepared-statement-cache-size>0</prepared-statement-cache-size>
                    <share-prepared-statements>false</share-prepared-statements>
                </statement>
            </xa-datasource>
            <drivers>
                <driver name="com.mysql" module="com.mysql">
                    <driver-class>com.mysql.jdbc.Driver</driver-class>
                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                </driver>
            </drivers>
like image 929
RBall444 Avatar asked Oct 13 '15 18:10

RBall444


1 Answers

The error you get means that wildfly expects a module called com.mysql but it doesn't exist or it isn't registered under that name.

You are missing one step, which is registering the datasource jdbc driver. The first step of course being adding the mysql-connector-java-5.1.35-bin.jar file and module.xml file in WILDFLY_HOME\modules\system\layers\base\com\mysql\main.

To get rid of your error, stop wildfly, delete the the driver declaration in your standalone.xml by removing these lines; We'll let the /subsystem command create this entry.

<driver name="com.mysql" module="com.mysql">
     <driver-class>com.mysql.jdbc.Driver</driver-class>
     <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>

Open your command prompt and navigate to WILDFLY_HOME\bin\ and run the following commands.

  1. Connect to jboss cli by running : jboss-cli.bat --connect . In case your management console is running on a different port say , localhost:9991, use jboss-cli.bat --connect --controller=127.0.0.1:9991

  2. Then register the jdbc-driver with the following command

    /subsystem=datasources/jdbc-driver=com.mysql:add(driver-name=com.mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)

You should get the response {"outcome" => "success"} if this was successful. From there, reload your server and you should get rid of that error.

I got pointers from This link

like image 128
mwangi Avatar answered Sep 20 '22 21:09

mwangi