Wildfly 10 failing to load MySQL XA driver on startup

血红的双手。 提交于 2019-12-05 10:27:59

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

I'm not really sure what the issue could be. The message isn't very informative.

That said the following add-mysql.cli script worked for me.

module add --name=com.mysql --resources=~/Downloads/mysql-connector-java-5.1.37/mysql-connector-java-5.1.37-bin.jar --dependencies=javax.api,javax.transaction.api

batch
/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)
/subsystem=datasources/xa-data-source=mysql:add(driver-name=com.mysql, jndi-name="java:/jdbc/MySQLXA", enabled=true)
/subsystem=datasources/xa-data-source=mysql/xa-datasource-properties=URL:add(value="jdbc:mysql://localhost:3306/temp?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8")
run-batch

I didn't write all the properties defined in your data source configuration, but this did work.

WildFly 10 has some change in jca caused CLI create xa ds have some issue. https://issues.jboss.org/browse/WFLY-6773 https://issues.jboss.org/browse/WFLY-6789 https://issues.jboss.org/browse/WFLY-6774

But create xa datasouces use below commands works

xa-data-source add --name=MariaDBXADS --driver-name=mariadb-xa --jndi-name=java:jboss/datasources/MariaDBXADS --user-name=jdv_user --password=jdv_pass --use-java-context=true --xa-datasource-properties=[DatabaseName=>products, PortNumber=>3306, ServerName=>localhost]

WILDFLY 10 using mysql 5.7

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

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

jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE h2 sa sa --> jdbc:mysql://localhost:3306/wildfly mysql root jdfoxito10 com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!