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:
Windows 7 Enterprise SP1
Oracle Java SE 1.8.0_45
WildFly 9.0.0.Final
MySQL Server 5.6
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.
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.
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.
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"/>
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
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.
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.
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.
Related
I have a JBoss EAP 6 instance, which has a couple of deployments (An EAR and a few WARs):
The thing is that on shutdown, I need myWar1.war to be undeployed after myEar.ear, but the actual result is that myEar.ear is being undeployed last, causing errors in the logs on shutdown due to the dependency.
I've already tried declaring dependencies of that war to the ear through jboss-deployment-structure.xml, and myWar1.war/WEB-INF/jboss-all.xml. Here are the examples:
myWar1.war/WEB-INF/jboss-deployment-structure.xml
<dependencies>
<module name="deployment.myEar.ear">
<imports>
<exclude path="***" />
</imports>
</module>
<module name="javax.annotation.api" />
</dependencies>
myWar1.war/WEB-INF/jboss-all.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="myEar.ear" />
</jboss-deployment-dependencies>
</jboss>
None of these solutions seem to work. Although, it looks like jboss-all.xml is being read and parsed by JBoss, but it makes no effect on the order of undeployment of the dependant WAR on the EAR. (I guess it's not the expected behaviour, as states HERE.)
All the WARs are being deployed through JBoss CLI (then the server is restarted), but the myEar.ear is being exploded inside the server /deployments, and it's also added as a deployment through the CLI. Here are the entries for that in standalone-full.xml.
Also, the WAR is a SpringBoot application, built and packaged by Maven.
standalone-full.xml
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-enabled="false" scan-interval="5000"/>
</subsystem>
<deployments>
. . .
<deployment name="myWar1.war" runtime-name="myWar1.war">
<content sha1="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
</deployment>
<deployment name="myEar" runtime-name="myEar.ear">
<fs-exploded path="$JBOSS_HOME/standalone/deployments/myEar.ear"/>
</deployment>
. . .
</deployments>
Is there another way I can alter the undeployment sequence when shutting down JBoss? Is there a way to make jboss-all.xml be recognized properly by JBoss, or I am missing some configuration?
The deployment dependencies tag in jboss-all.xml is usually referenced only for ensuring applications deploy after dependencies are established (As in your example myear has to be deployed before mywar1 deploys) but not for shutdown.
Commonly JBoss' command line commands (look up JBoss CLI) are used to handle startup, deployments and shutdowns, but the CLI is not meant to be invoked from within your program's code. There is a parallel api called the Management API, for the management interface, which has shutdown/startup functionality, and which is meant to be called from within your code.
The AS7 Management API is applicable to the JBoss EAP 6.x, as should the newest Wildfly version of the API. Only the wildfly api is supposed to be the most updated page for the API and it lists the startup/shutdown procedures though YMMV. Here is the wildfly API and the 6.x/AS7 api in case you run into issues using the wildfly reference. Here is how to use the Management Interface API programmatically.
I'm running an Wildfly 9 Application-Server and everything is deployed with "mvn clean install wildfly:deploy" except 2 War Files that are in the wildfly/standalone/deployments folder and are deployed automatically.
My Problem now is: Every other package has to use the 2 war Files (because its a database) and i can't find a way to tell Wildfly to first deploy the files in the deployment folder and then start to deploy the rest.
At the moment i'm working with TimerServices for each Package till the Database is deployed and running, but that is a real bad solution in my Opinion.
Do you know a way to solve this?
Thx in advance
You could create a jboss-deployment-structure.xml to build a dependency from your deployments.
For example, assuming your two wars deployed automatically are named 'alpha.war'/ 'betha.war' and your 'dependent' deployment is called 'omega.war', you just have to create (or edit) the file:
omega.war/WEB-INF(or META-INF for ears)/jboss-deployment-structure.xml
with the content...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module export="true" name="deployment.alpha.war"/>
<module export="true" name="deployment.betha.war"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
I am working on a web service application on JBoss EAP 6.1.0, which requires a datasource for SQL Server 2008 to be created. I have downloaded and extracted the sqljdbc jar file, but am not sure where it goes on the application server. I tried referencing the EAP 6.1 configuration guide and a couple of other websites, but that did not help. I would be very grateful if someone could guide me with the steps to register the datasource on the application server.
It goes into your modules folder. You have have something like the following:
<JBOSS_HOME>\modules\com\microsoft\sqlserver\main
Your sqljdbc would be inside the folder structure above. You would also need to create a module.xml file in the same folder similar to:
<module xmlns="urn:jboss:module:1.1" name="com.microsoft.sqlserver">
<resources>
<resource-root path="sqljdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Then finally in your standalone.xml, the datasources section should have a drivers definition that references your module as such:
<drivers>
<driver name="sqlserver" module="com.microsoft.sqlserver">
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
</driver>
</drivers>
Hope that helps
The server startup error message is:
16:08:37,829 ERROR [org.jboss.as.controller.management-operation] (ServerService
Thread Pool -- 27) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("jdbc-driver" => "firebird")
]) - failure description: "JBAS010441: Failed to load module for driver [org.fir
ebirdsql]"
Content of module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="org.firebirdsql">
<resources>
<resource-root path="jaybird-2.2.5.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.resource"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Driver definition in standalone.xml:
<driver name="firebird" module="org.firebirdsql">
<driver-class>org.firebirdsql.jdbc.FBDriver</driver-class>
</driver>
(Based on http://masterjboss.blogspot.de/2014/03/how-to-configure-mysql-jdbc-driver-in.html)
A similar problem (without accepted answer): Db2 Driver/Datasource setup on wildfly: Failed to load module for driver [com.ibm]
Replace <module name="javax.resource"/> with <module name="javax.resource.api"/> in the dependencies section.
I have installed WildFly 8.1 and added the module under:
<wildfly-root>\modules\org\firebirdsql\main\
module.xml
jaybird-2.2.5.jar
Note that this doesn't match the location used in the tutorial you link to. The tutorial - incorrectly - roots user modules in modules\system\layers\base instead of modules\, but when I place the module there it works as well.
My module.xml definition has content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.firebirdsql">
<resources>
<resource-root path="jaybird-2.2.5.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.resource.api"/>
</dependencies>
</module>
I added the driver entry to standalone.xml exactly as you posted. And then added a datasource in the management console, and tested the connection.
This works. My earlier theory in the comments that it isn't working for you due to the Web Profile not including Resource Connectors seems to be wrong. I have also tested using a Java 8 version of Jaybird when WildFly is running on Java 7, but this gives an UnsupportedClassVersionError as expected.
The only way I have been able get the error in your question is to intentionally misplace the module (eg deleting it entirely, having a spelling error in the folder names, or putting it in the wrong location). I would suggest that you carefully check your module location (see above).
See the answer by asohun for the solution to your specific problem. I will leave this answer in place as it contains the correct config and an alternative failure mode that produces the same error.
I want to set a mysql data source in jboss standalone mode. I have already deploy the mysql-connector-java-5.1.15-bin.jar and set the below data source configuration in standalone.xml under datasources
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/testdb</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
</security>
</datasource>
And when i click on the configured data source name in the web console im getting below error,
Internal server error{
"outcome" => "failed",
"failure-description" => "JBAS014739: No handler for read resource at address [
(\"subsystem\"=>"\datasource\"),
(\"data-source\"=>"\MySqlDS\"),
(\"statstics\"=>"\pool\"),
"],
"roleback" => "true"
}
I didnt add any thing to the drivers section since it not nessaccary,
Below one is set to the sample data source set in jboss
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class
</driver>
</drivers>
What i am missing here please?
You will also need to specify driver class
<driver-class>com.mysql.jdbc.Driver</driver-class>
Checkout this link How do I migrate my application from AS5 or AS6 to AS7
I've experienced the same issue under the same circumstances. The problem was that my AS didn't have the required module for PostgreSQL. Check in jboss/modules/org if you have a folder named postgresql. If not then create it. Then create a directory in it named main.
You then have to have two files present in there:
PostgreSQL JDBC JAR
module.xml configuration file
Download the JAR file according to the database you're using and copy it here. As for the module.xml just create a new file and set up the configuration. Mine looks like this, customize it for your case:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.3-1100.jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Basically you just have to change the resource path to where your JAR file is.
This is an issue with JBOSS, it doesn't warn you even though the JDBC driver is missing. I've wasted a ton of time finding this hidden bug :D