将 MySql 添加到 JBoss 8.1 (Wildfly)

Posted

技术标签:

【中文标题】将 MySql 添加到 JBoss 8.1 (Wildfly)【英文标题】:Adding MySql to JBoss 8.1 (Wildfly) 【发布时间】:2014-11-17 13:52:00 【问题描述】:

所以我遵循了这个教程:https://zorq.net/b/2011/07/12/adding-a-mysql-datasource-to-jboss-as-7/

我已经按照教程中的描述做了所有事情;但我在启动时不断收到此错误:

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]

这是我在 Jboss 文件夹中的模块目录的结构:modules/com/mysql/main 有两个文件 module.xmlmysql-connector-java-5.1.34.jar

这是我的 module.xml 文件:

<?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>

我还在standalone/deployments中添加了mysql jar

这是我在standalone.xmlstandalone/configuration下我的datasource和driver的配置

 <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"/>

【问题讨论】:

【参考方案1】:

我发现我的错误,我不得不将我的 module.xml 和 jar 放在系统模块下,而不是创建一个新的 com 文件夹

【讨论】:

以上是关于将 MySql 添加到 JBoss 8.1 (Wildfly)的主要内容,如果未能解决你的问题,请参考以下文章

EJB 远程客户端从 JBoss AS 7.1 迁移到 Wildfly 8.1

WildFly jboss-cli.sh 添加数据源 Mysql 与 useSSL=false

JBOSS 4.2.1和JRE1.8.1xx兼容? JBoss的4.2.1GA JSP问题

"WFLYCTL0412: 未安装的必需服务:" => ["jboss.jdbc-driver.mysql"]

JBOSS 7 MYSQL 缺少依赖项错误

找不到 mysql.jdbc.Driver - MySQL、JBoss