Reputation: 55
I am creating a web application for WildFly, which will connect to a MySQL database through JPA (Hibernate). For now, I am just trying to get WildFly to start up and load the MySQL driver in standalone mode. I am using this page as a guide: http://wildfly.org/news/2014/02/06/GlassFish-to-WildFly-migration/
I am running WildFly and MySQL locally on a Windows system:
Attempts to use the recommended console commands did not succeed, so I have manually edited to WildFly configuration files to look like those in the examples on the page linked above. First, I created the module directory and placed in it the MySQL connector JAR and module.xml file:
Directory of C:\wildfly-9.0.0.Final\modules\system\layers\base\com\mysql\main
07/06/2015 09:54 AM <DIR> .
07/06/2015 09:54 AM <DIR> ..
07/06/2015 10:12 AM 334 module.xml
07/01/2015 02:38 PM 968,668 mysql-connector-java-5.1.35.jar
The above connector jar was copied from my local Maven repository, which Maven obtained through the following dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.35</version>
</dependency>
The module.xml file was manually edited as follows, to resemble the example I found on wildfly.org:
<?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>
Finally, I added the driver and datasource to the datasources section of standalone.xml:
<datasource jndi-name="java:/MySQLDS" pool-name="MyDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/mydb</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>secret</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
</drivers>
Upon starting WildFly in standalone mode, by running %WILDFLY_HOME%\bin\standalone.bat, the following is the first error listed in %WILDFLY_HOME%\standalone\logs\server.log:
2015-07-06 10:25:47,321 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 33) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]) - failure description: "WFLYJCA0041: Failed to load module for driver [com.mysql]"
Similar issues that I have seen posted on Stack Overflow and other question/answer sites usually point to an oversight such as a typo in config files or a misnamed file. However, I've been over this over and over and cannot see any such mistake, and the same error has occurred even after upgrading from Java SE 7 and WildFly 8.2 and re-creating the configuration files from scratch. Any assistance would be greatly appreciated.
Upvotes: 4
Views: 12039
Reputation: 1
Maybe two solutions for your issue:
You forgot the attribute slot
on module
element in module.xml
file,
e.g.:
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql" slot="main">
<resources>
<resource-root path="postgresql-9.4.1212.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
add code slot="main"
in module
element, it will take effect.
If above approach doesn't work, it is considered with XML Module descriptors . The same issue with Wildfly Failed to Load Module for Oracle Driver:
Change the namespace version of module
element in module.xml
.
enjoy it.
Upvotes: -1
Reputation: 19
I know it has been while but that may help for others. The recommended approach is to deploy a driver is using the wildfly console (localhost:9990/console). once you deployed the driver jar then create your DS again by using the console then it will create it automatically in the standalone.xml. Sometimes, when doing those stuffs manually may cause missing tiny details which drive us crazy.
Upvotes: 0
Reputation: 7789
In my case, it was an issue with double quotes. When I copied a WordPress sample of module.xml, I got (note the curly quotes):
<resource-root path=”postgresql-9.4.1211.jar”/>
... but Wildfly is very picky and needs this (straight quotes):
<resource-root path="postgresql-9.4.1211.jar"/>
Upvotes: 2
Reputation: 17418
In my case I have missed the main
folder which module.xml and connector jar file need to be included.
Earlier it was
JBOSS_HOME\modules\system\layers\base\com\mysql\module.xml
and the correct path should be,(module.xml and jar needed be included inside of main)
JBOSS_HOME\modules\system\layers\base\com\mysql\main\module.xml
Upvotes: 1
Reputation: 1
For me, it seems to be a coding problem. Before the tag
<module>
...
</module>
in my module.xml file, there is a mysterious blank, which is not utf-8 or English, causing my failure. After I deleted the blank or changed it to an English one. Everything is ok. Also, I looked for some solutions to this problem. Most of them can be summed to the module.xml file's problem. A name typo or the content coding. Hope it heplful for others.
Upvotes: -1
Reputation: 56
In my case it was a matter of having the wrong user:group for the directories and files under ../com/mysql/main
I changed it to wildlfy and everything worked as expected.
Upvotes: 4
Reputation: 55
There was a typo in module.xml. The name of the connector JAR listed in module.xml did not match the actual JAR file in modules\system\layers\base\com\mysql\main.
Upvotes: 2