I'm trying to move my Tomcat web service to Wildfly 10. I thought it should be drag and drop into Wildfly's deployment folder and everything should be fine, but it seems not like that.
This is my MariaDB datasource definition in standalone.xml:
jdbc:mariadb://db_ip/db_name
mariadb
dbAcc
dbPassword
true
false
org.mariadb.jdbc.Driver
org.mariadb.jdbc.MariaDbDataSource
then I put mariadb-java-client-1.4.6.jar and my WAR file into wildfly/standalone/deployments, start the Wildfly, and error messages came into my eyes:
07:05:21,137 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 60) WFLYUT0021: Registered web context: /MySV
07:05:21,143 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "MariaDBDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mariadb"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/MariaDBDS is missing [jboss.jdbc-driver.mariadb]",
"org.wildfly.data-source.MariaDBDS is missing [jboss.jdbc-driver.mariadb]"
]
}
07:05:21,148 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "MariaDBDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.mariadb",
"jboss.jdbc-driver.mariadb"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/MariaDBDS is missing [jboss.jdbc-driver.mariadb]",
"org.wildfly.data-source.MariaDBDS is missing [jboss.jdbc-driver.mariadb]",
"org.wildfly.data-source.MariaDBDS is missing [jboss.jdbc-driver.mariadb]"
]
}
I cannot let my service connect to DB, do I missed any step?
解决方案
If I look at your configuration, you setup the driver to be a module. So you create it as a module in your server rather than deploying it as a separate jar in the deployments folder.
If you want to setup a datasource where the driver is in the deployments folder, you do something like this:
jdbc:mariadb://db_ip/db_name
mariadb-java-client-1.4.6.jar
org.mariadb.jdbc.Driver
dbAcc
dbPassword
true
false
No separate driver declaration needed, its all contained within the datasource configuration.