问题
I am busy upgrading from JBoss 7.1.1 to Wildfly 8.0.0.Beta1. I was using the JTDS database driver under JBoss without problems, but it is not working under WildFly.
I have creates the /net/sourceforge/jtds/main/
folder structure under modules
in my WildFly installation and added the module.xml
file, but Wildfly doesn't seem to be picking it up.
I have also tried the /modules/system/layers/base/
folder as this is a new one under WildFly, but that doesn't work either and I have downloaded the latest JTDS .JAR file too.
The error I get when I start Wildfly is:
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "SCI_ODS_sql2")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:jboss/datasources/SCI_ODS is missing [jboss.jdbc-driver.JTDS]",
"jboss.driver-demander.java:jboss/datasources/SCI_ODS is missing [jboss.jdbc-driver.JTDS]"
]}
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "SCI_ODS_sql2")
]) - failure description: {
"JBAS014771: Services with missing/unavailable dependencies" => [
"jboss.data-source.java:jboss/datasources/SCI_ODS is missing [jboss.jdbc-driver.JTDS]",
"jboss.driver-demander.java:jboss/datasources/SCI_ODS is missing [jboss.jdbc-driver.JTDS]"
],
"JBAS014879: One or more services were unable to start due to one or more indirect dependencies not being available." => {
"Services that were unable to start:" => [
"jboss.data-source.reference-factory.SCI_ODS_sql2",
"jboss.naming.context.java.jboss.datasources.SCI_ODS"
],
"Services that may be the cause:" => ["jboss.jdbc-driver.JTDS"]
}
}
If I run /subsystem=datasources:installed-drivers-list
uon jboss-cli.sh
it only shows the h2 driver that is installed by default and not the JTDS one.
回答1:
I hadn't setup the driver in standalone.xml
properly. I had convinced myself that I'd done that already. Added:
<driver name="JTDS" module="net.sourceforge.jtds">
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<xa-datasource-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</xa-datasource-class>
</driver>
回答2:
First, stop the WildFly server.
Then update standalone.xml file to add MS-SQL JTDS driver details and Datasource details like below:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jta="true" jndi-name="java:/jdbc/speedtest-datasource" pool-name="MSSQLDSspeedTestDEV" enabled="true" use-ccm="true">
<connection-url>jdbc:jtds:sqlserver://serverName:1433;DatabaseName=dbName</connection-url>
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<driver>JTDS</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
<background-validation>true</background-validation>
</validation>
</datasource>
<drivers>
<driver name="JTDS" module="net.sourceforge">
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
</driver>
</drivers>
</datasources>
</subsystem>
Module.xml for MS SQL JTDS: path : E:\Softwares\wildfly-10.1.0.Final\wildfly-10.1.0.Final\modules\system\layers\base\net\sourceforge\main ( need to create directory structure as highlighted and add module.xml and jtds-1.3.0.jar files).
(note in this example i have used module name as "net.sourceforge" and created the folder structure path as "net\sourceforge\main"). Please note this is more important to match the directory path and module name in module,xml file.
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="net.sourceforge">
<resources>
<resource-root path="jtds-1.3.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Note: Please note that the path highlighted in green above at 2 places should match (ie directory structure and module name in module.xml),
For example. If you have created directory structure as E:\Softwares\wildfly-10.1.0.Final\wildfly-10.1.0.Final\modules\system\layers\base\net\sourceforge\jtds\main then module name in module.xml file should be “net.sourceforge.jtds” as shown below in module.xml file
Module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="net.sourceforge.jtds">
<resources>
<resource-root path="jtds-1.3.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Now save these two files and restart the wildFLY server.
来源:https://stackoverflow.com/questions/20190703/jtds-module-under-wildfly-jboss