我尝试使用MySQL在Wildfly 8.1中配置数据源。我在Windows上的本地环境中,当我启动服务器时,我一直收到错误。数据源已注册,但在测试时失败。
我在C:\ wildfly \ modules \ system \ layers \ base \ com \ mysql \ main
中有mysql连接器jar文件standalone.xml
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/bookdb</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>*******</password>
</security>
<timeout>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>600</query-timeout>
</timeout>
</datasource>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
module.xml C:\ wildfly \ modules \ system \ layers \ base \ com \ mysql \ main
<?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.38-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
00:46:17,927错误[org.jboss.as.controller.management-operation] (ServerService线程池 - 27)JBAS014613:操作(&#34;添加&#34;)失败 - 地址: ([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34; jdbc-driver&#34; =&gt;&#34; mysql&#34;)]) - 失败描述:&#34; JBAS010441:无法加载驱动程序模块[com.mysql]&#34; 00:46:17,912 INFO [org.jboss.as.connector.deployers.jdbc](MSC服务主题1-4) JBAS010417:已启动驱动程序服务,驱动程序名称= h2 00:46:18,171 INFO [org.wildfly.extension.undertow](MSC服务线程1-2) JBAS017525:已启动服务器默认服务器。 00:46:18,165 INFO [org.wildfly.extension.undertow](ServerService线程池 - 47) JBAS017527:为路径C:\ wildfly / welcome-content创建文件处理程序 00:46:18,498 INFO [org.wildfly.extension.undertow](MSC服务 线程1-1)JBAS017531:主机默认主机启动00:46:18,558 INFO [org.jboss.remoting](MSC服务主题1-6)JBoss Remoting版本 4.0.3.Final 00:46:18,694 INFO [org.jboss.as.server.deployment.scanner](MSC服务主题1-3) JBAS015012:为目录启动了FileSystemDeploymentService C:\ wildfly \ standalone \ deployments 00:46:18,701 INFO [org.wildfly.extension.undertow](MSC服务线程1-1)JBAS017519: 在/127.0.0.1:8080上取消对HTTP侦听器的默认侦听 00:46:18,863 INFO [org.jboss.as.connector.subsystems.datasources] (MSC服务线程1-2)JBAS010400:绑定数据源 [java:jboss / datasources / ExampleDS] 00:46:19,112 INFO [org.jboss.ws.common.management](MSC服务主题1-7)JBWS022052: 启动JBoss Web服务 - Stack CXF Server 4.2.4.Final 00:46:19,122 ERROR [org.jboss.as.controller.management-operation] (控制器启动线程)JBAS014613:操作(&#34;添加&#34;)失败 - 地址: ([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34;数据源&#34; =&gt;&#34; MySQLDS&#34;)]) - 失败描述:{&#34; JBAS014771:具有丢失/不可用依赖关系的服务&#34; =&GT; [ &#34; jboss.data-source.java:缺少jboss / datasources / MySQLDS [jboss.jdbc-driver.mysql]&#34;, &#34; jboss.driver-demander.java:缺少jboss / datasources / MySQLDS [jboss.jdbc-driver.mysql]&#34; ]} 00:46:19,155错误 [org.jboss.as.controller.management-operation](控制器启动 线程)JBAS014613:操作(&#34;添加&#34;)失败 - 地址:([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34;数据源&#34; =&gt;&#34; MySQLDS&#34;)]) - 失败说明:{ &#34; JBAS014771:具有缺失/不可用依赖性的服务&#34; =&GT; [ &#34; jboss.data-source.java:缺少jboss / datasources / MySQLDS [jboss.jdbc-driver.mysql]&#34;, &#34; jboss.driver-demander.java:缺少jboss / datasources / MySQLDS [jboss.jdbc-driver.mysql]&#34; ] &#34; JBAS014879:由于一个或多个间接依赖项不可用,一个或多个服务无法启动。&#34; =&GT; { &#34;无法启动的服务:&#34; =&GT; [ &#34; jboss.data-source.reference-factory.MySQLDS&#34 ;, &#34; jboss.naming.context.java.jboss.datasources.MySQLDS&#34; ] &#34;可能是原因的服务:&#34; =&GT; [&#34; jboss.jdbc-driver.mysql&#34;] 00:46:19,254 INFO [org.jboss.as.controller](控制器启动线程)JBAS014774:服务状态报告JBAS014775:新增 缺失/不满意的依赖: service jboss.jdbc-driver.mysql(missing)dependents:[service jboss.driver-demander.java:jboss/datasources/MySQLDS,service jboss.data-source.java:jboss/datasources/MySQLDS]
00:46:19,616 INFO [org.jboss.as](控制器启动线程)JBAS015961: Http管理界面监听 http://127.0.0.1:9990/management 00:46:19,628 INFO [org.jboss.as] (控制器启动线程)JBAS015951:管理控制台正在侦听 http://127.0.0.1:9990 00:46:19,643 ERROR [org.jboss.as](控制器 引导线程)JBAS015875:WildFly 8.1.0.Final&#34; Kenny&#34;开始(用 错误)在4876ms - 238个服务中的185个(4个服务失败或 缺少依赖关系,81个服务是懒惰的,被动的或按需的) 00:51:40,780 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread-4)JBAS014613:操作(&#34;添加&#34;)失败 - 地址: ([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34; jdbc-driver&#34; =&gt;&#34; mysql-5-driver&#34;)]) - 失败描述:&#34; JBAS010441:无法加载驱动程序模块[mysql]&# 34; 00:51:47961 错误[org.jboss.as.controller.management-operation] (management-handler-thread-6)JBAS014613:操作(&#34;添加&#34;)失败 - 地址: ([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34; jdbc-driver&#34; =&gt;&#34; mysql-5-driver&#34;)]) - 失败描述:&#34; JBAS010441:无法加载驱动程序模块[mysql]&# 34; 00:53:21929 错误[org.jboss.as.controller.management-operation] (management-handler-thread-8)JBAS014613:操作(&#34;添加&#34;)失败 - 地址: ([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34; jdbc-driver&#34; =&gt;&#34; mysql-5-driver&#34;)]) - 失败描述:&#34; JBAS010441:无法加载驱动程序模块[com.mysql] &#34; 01:01:49,324 ERROR [org.jboss.as.controller.management-operation] (XNIO-1任务-7)JBAS014613:操作(&#34; test-connection-in-pool&#34;) 失败 - 地址:([ (&#34;子系统&#34; =&gt;&#34;数据源&#34;), (&#34;数据源&#34; =&gt;&#34; MySQLDS&#34;)]) - 失败描述:&#34; JBAS010440:无法调用操作:JBAS010442:无法匹配 池。检查JndiName:java:jboss / datasources / MySQLDS&#34;
谢谢!
答案 0 :(得分:0)
通过浏览器控制台上传MySQL连接器.jar文件作为部署修复了该问题。
我的数据源在WildFly 10x中运行,因此我不知道版本8.1是否存在问题。
以下是向Wildfly添加数据源的3种方式的视频:https://www.youtube.com/watch?v=xSHXMcRsF0A