概述
jboss-eap-6.3集成OracleDS和MySqlDS
Oracl:
在D:toolsjbossjboss-eap-6.3modulessystemlayersbasecom目录下新建oraclemain文件夹:
在此文件夹下添加ojdbc14-10.2.0.4.0.jar和module.xml,内容如下:
3. 修改D:toolsjbossjboss-eap-6.3standaloneconfigurationstandalone.xml文件,添加如下代码:
jdbc:oracle:thin:@127.0.0.1:1521:ORCL
oracle
false
false
FailingConnectionOnly
scott
tigger
oracle.jdbc.driver.OracleDriver
com.mysql.jdbc.Driver
MySql:
在D:toolsjbossjboss-eap-6.3modulessystemlayersbasecom目录下新建mysqlmain文件夹:
在此文件夹下添加mysql-connector-java-5.1.29.jar(注意:使用5.1.29以上的版本会报错,详见本文扩展部分)和module.xml,内容如下:
3.修改D:toolsjbossjboss-eap-6.3standaloneconfigurationstandalone.xml文件,添加如下代码:
jdbc:mysql://127.0.0.1:3306/demo
mysql
root
root
com.mysql.jdbc.Driver
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
扩展:
集成mysql开始时使用了:mysql-connector-java-5.1.34.jar,启动时报错:
12:23:10,872 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010404: 部署不兼容 JDBC 的驱动 class com.mysql.fabric.jdbc.FabricMySQLDriver (版本 5.1)
12:23:10,880 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 25) JBAS014612: 操作("add") 失败 -- 地址:([
("subsystem" => "datasources"),
("jdbc-driver" => "mysql")
]): org.jboss.msc.service.DuplicateServiceException: Service jboss.jdbc-driver.mysql is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:158) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:236) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:742) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:243) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2433) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:345) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
at org.jboss.as.controller.OperationContextImpl$ContextServiceBuilder.install(OperationContextImpl.java:1672) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.startDriverServices(JdbcDriverAdd.java:160)
at org.jboss.as.connector.subsystems.datasources.JdbcDriverAdd.performRuntime(JdbcDriverAdd.java:118)
at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:75) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:611) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:489) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.controller.AbstractOperationContext.completeStepInternal(AbstractOperationContext.java:290) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:285) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:354) [jboss-as-controller-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
分析错误原因,mysql驱动加载重复了,部署的JDBC 的驱动 class com.mysql.fabric.jdbc.FabricMySQLDriver正常,但紧接着又部署了一个mysql的数据源,连接mysql时驱动一般是com.mysql.jdbc.Driver,为什么现在是com.mysql.fabric.jdbc.FabricMySQLDriver呢.
换成mysql-connector-java-5.1.29.jar后就不报错了.比较了jar后得知从mysql-connector-java-5.1.30.jar开始jar中多出了fabric的驱动,在META-INFservicesjava.sql.Driver文件中包含两行
com.mysql.jdbc.Driver
com.mysql.fabric.jdbc.FabricMySQLDriver
而5.1.29中只包含一行
com.mysql.jdbc.Driver.
那么,fabric究竟是什么呢,见下面的文章http://www.mysql.com/products/enterprise/fabric.html
最后
以上就是幸福白猫为你收集整理的jboss eap mysql_jboss-eap-6.3集成OracleDS和MySqlDS配置的全部内容,希望文章能够帮你解决jboss eap mysql_jboss-eap-6.3集成OracleDS和MySqlDS配置所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复