Adding MySql to JBoss 8.1 (Wildfly)

2019-09-17 20:07发布

So I have followed this tutorial: https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7/

I have done everything as described in the tutorial; yet I keep getting this error on start up:

14:42:19,442 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "ExpensesDataSourcePool")
]) - failure description: {"JBAS014771: Services with missing/unavailable dependencies" => [
    "jboss.data-source.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]",
    "jboss.driver-demander.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]"
]}
14:42:19,450 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([
    ("subsystem" => "datasources"),
    ("data-source" => "ExpensesDataSourcePool")
]) - failure description: {
    "JBAS014771: Services with missing/unavailable dependencies" => [
        "jboss.data-source.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]",
        "jboss.driver-demander.java:/ExpensesDataSource is missing [jboss.jdbc-driver.mysql]"
    ],
    "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.ExpensesDataSourcePool",
            "jboss.naming.context.java.ExpensesDataSource"
        ],
        "Services that may be the cause:" => ["jboss.jdbc-driver.mysql"]
    }
}
14:42:19,489 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "mysql-connector-java-5.1.34.jar" (runtime-name : "mysql-connector-java-5.1.34.jar")
14:42:19,491 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/ExpensesDataSource, service jboss.driver-demander.java:/ExpensesDataSource]

This is the structure of my modules dir in the Jboss folder: modules/com/mysql/main with two files module.xml and mysql-connector-java-5.1.34.jar

This is my module.xml file:

<?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.34.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
  </dependencies>
</module>

I have also added the mysql jar in standalone/deployments

This is the configuration of my datasource and driver in my standalone.xml under standalone/configuration

 <datasource jndi-name="java:/ExpensesDataSource" pool-name="ExpensesDataSourcePool" enabled="true" use-java-context="true">
                    <connection-url>jdbc:mysql://localhost:3306/expenses</connection-url>
                    <driver>mysql</driver>
                    <security>
                        <user-name>root</user-name>
                        <password>root</password>
                    </security>
                </datasource>


                <driver name="mysql" module="com.mysql"/>

标签: mysql jboss
1条回答
女痞
2楼-- · 2019-09-17 20:39

I found my error, I had to put my module.xml and jar under system modules instead of creating a new com folder

查看更多
登录 后发表回答