Wildfly 10.1.0 - 未找到 Mysql 数据源
Posted
技术标签:
【中文标题】Wildfly 10.1.0 - 未找到 Mysql 数据源【英文标题】:Wildfly 10.1.0 - Mysql Datasource not found 【发布时间】:2017-05-03 08:11:41 【问题描述】:我知道,这个问题是建立在所有 google 和 *** 上的,但是我的问题没有解决,我也没有找到解决方案 =/
所以,很简单,我的 WildFly 似乎看不到我的 mysql 连接器。
我尝试使用 mysql-connector-java-5.1.38
module.xml (wildfly-10.1.0.Final\modules\system\layers\base\com\mysql\main)
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.38.jar"/>
</resources>
<dependencies>
<modue name="javax.api"/>
</dependencies>
</module>
在 mysql-connector-java-5.1.38 上尝试使用和不使用“.jar”
数据源
<datasources>
<datasource jndi-name="java:/budget-datasource" pool-name="budget-datasource" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/budget?zeroDateTimeBehavior=convertToNull</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
</security>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
我尝试替换
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
通过
<driver>com.mysql.jdbc.Driver</driver>
但没用
完整有趣的堆栈跟踪 错误 [org.jboss.as.controller.management-operation] (ServerService 线程池 -- 33) WFLYCTL0013: 操作 ("add") 失败 - 地址: ([ (“子系统”=>“数据源”), ("jdbc-driver" => "mysql")
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "budget-datasource")
]) - failure description:
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.mysql"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:/budget-datasource is missing [jboss.jdbc-driver.mysql]"
]
ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "budget-datasource")
]) - failure description:
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.mysql",
"jboss.jdbc-driver.mysql"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]",
"jboss.driver-demander.java:/budget-datasource is missing [jboss.jdbc-driver.mysql]",
"org.wildfly.data-source.budget-datasource is missing [jboss.jdbc-driver.mysql]"
]
INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.driver-demander.java:/budget-datasource, service org.wildfly.data-source.budget-datasource]
我使用Eclipse Mars开发p,需要配置项目使用mysql连接器吗?
提前谢谢你的帮助,我很迷茫
我找到了解决方案:
<modue name="javax.api"/>
<module name="javax.api"/>
【问题讨论】:
以下建议的解决方案是否有效? 【参考方案1】:然后创建一个mysql模块,尝试另一种方法:
1)在Wildfly上部署jar mysql-connector-java-5.1.38.jar
2)如下设置数据源
<datasources>
<datasource jndi-name="java:/budget-datasource" pool-name="budget-datasource" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/budget?zeroDateTimeBehavior=convertToNull</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql-connector-java-5.1.38.jar</driver>
<security>
<user-name>root</user-name>
</security>
</datasource>
</datasources>
【讨论】:
【参考方案2】:Absent one mandatory step : you need to reference the module as a driver in WildFly configuration with the following jboss-cli command.
The Command Line
All admin operations can be also done through the command line. To activate WildFly command line prompt start WildFly, go to the WILDFLY_HOME/bin folder and execute the command:
#> jboss-cli.sh(.bat) --connect
It connects to localhost and port 9990 by default. The prompt looks like [standalone@localhost:9990 /], indicating it is ready to accept admin commands. Type quit when you are done. Command line examples are spreaded througout the text. Before using them, please remove all line breaks and identation spaces, making them a continous text string. For example:
Instead of doing exactly this:
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(
driver-name=mysql,
driver-module-name=com.mysql,
driver-class-name=com.mysql.jdbc.Driver
)
You should do this:
[standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-class-name=com.mysql.jdbc.Driver)
这将解决问题,驱动器出现在 WildFly 10 的注册驱动程序列表中
【讨论】:
【参考方案3】:在你的 model.xml 中简单定义:
<resources>
<resource-root path="mysql-connector-java-8.0.11.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
【讨论】:
【参考方案4】:这个问题的一个解决方案:编辑standalone.xml,在bloc中添加这一行
<driver name="mysql" module="com.mysql"/>
例子
<drivers>
<driver name="mysql" module="com.mysql"/>
</drivers>`
【讨论】:
以上是关于Wildfly 10.1.0 - 未找到 Mysql 数据源的主要内容,如果未能解决你的问题,请参考以下文章
WildFly 9.0.1 WFLYCTL0158 处理程序“控制台”未找到
Wildfly 安全子系统:从 Legacy 迁移到 Elytron,未找到安全域
JAX-RS (Resteasy 3.5.0.Final) + Wildfly 12 + Java 9 + maven = 404 未找到,但 JAX-RS (Resteasy 3.5.0.Final
Wildfly 10.1.0 Final Remoting端点任务线程不断增长
如果我不使用某些模块,是不是必须将所有模块都包含在 wildfly10.1.0 Standalone.xml 中?
jboss-6.0.0.Final 与 wildfly-10.1.0.Final 中的每个用户数据源连接池(通过安全域)