Wildfly 数据源与 DefaultDS 冲突
Posted
技术标签:
【中文标题】Wildfly 数据源与 DefaultDS 冲突【英文标题】:Wildfly Datasource conflicting with DefaultDS 【发布时间】:2014-03-17 22:50:03 【问题描述】:我从 jboss 7.1 迁移到 wildfly,但我的数据源有一些问题。
10:04:37,900 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017502: Undertow 1.0.0.Final starting
10:04:37,901 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017502: Undertow 1.0.0.Final starting
10:04:37,903 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 50) JBAS015537: Activating WebServices Extension
10:04:37,904 INFO [org.jboss.as.security] (MSC service thread 1-3) JBAS013170: Current PicketBox version=4.0.20.Final
10:04:37,913 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.0)
10:04:37,919 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010417: Started Driver service with driver-name = postgresql
10:04:37,924 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
10:04:37,926 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-13) JBAS010417: Started Driver service with driver-name = h2
10:04:37,939 INFO [org.jboss.as.naming] (MSC service thread 1-9) JBAS011802: Starting Naming Service
10:04:37,939 INFO [org.jboss.as.mail.extension] (MSC service thread 1-10) JBAS015400: Bound mail session [java:jboss/mail/Default]
10:04:38,013 INFO [org.jboss.remoting] (MSC service thread 1-11) JBoss Remoting version 4.0.0.Final
10:04:38,023 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017527: Creating file handler for path C:\bin\wildfly-8.0.0.Final/welcome-content
10:04:38,044 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017525: Started server default-server.
10:04:38,061 INFO [org.wildfly.extension.undertow] (MSC service thread 1-14) JBAS017531: Host default-host starting
10:04:38,231 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-14) JBAS015012: Started FileSystemDeploymentService for directory C:\bin\wildfly-8.0.0.Final\standalone\deployments
10:04:38,398 INFO [org.wildfly.extension.undertow] (MSC service thread 1-11) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080
10:04:38,530 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:/jdbc/hq]
10:04:38,531 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:04:38,531 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-11) JBAS010400: Bound data source [java:/jdbc/dice]
10:04:38,641 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.3.Final
当我查看日志时,我看到 Wildfly 部署了我的 dice 数据源并将其绑定到 [java:/jdbc/dice]。它在我的持久化 xml 中被引用。
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="dice">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/dice</jta-data-source>
现在我想在启动时检查一些数据源设置以确保隔离级别等:
@Singleton
@Startup
public class ConfigService
@Resource(name = "java:/jdbc/dice")
private DataSource dataSource;
在启动方法中,我只做以下事情:
Connection connection = dataSource.getConnection();
boolean autoCommit = connection.getAutoCommit();
int isolationLevel = connection.getTransactionIsolation();
在启动时我总是得到:
10:04:56,948 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-15) MSC000001: Failed to start service jboss.deployment.unit."dice.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."dice.war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "dice.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
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]
Caused by: java.lang.IllegalArgumentException: JBAS011053: Incompatible conflicting binding at java:/jdbc/dice source: lookup (java:comp/DefaultDataSource)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:243)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:184)
at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:152)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:145)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
... 5 more
10:04:56,959 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "dice.war")]) - failure description:
"JBAS014671: Failed services" => "jboss.deployment.unit.\"dice.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"dice.war\".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment \"dice.war\"
Caused by: java.lang.IllegalArgumentException: JBAS011053: Incompatible conflicting binding at java:/jdbc/dice source: lookup (java:comp/DefaultDataSource)",
"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"dice.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"dice.war\".beanmanager]"]
10:04:57,112 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "dice.war" (runtime-name : "dice.war")
10:04:57,113 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.deployment.unit."dice.war".beanmanager (missing) dependents: [service jboss.deployment.unit."dice.war".weld.weldClassIntrospector]
JBAS014777: Services which failed to start: service jboss.deployment.unit."dice.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."dice.war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "dice.war"
如果我更改数据源注入的 jndi 名称,它会起作用(例如,仅限 dice),但我不明白为什么。我做错了什么?
问候, 米
【问题讨论】:
您不必将整个名称放在`@Resource(lookup = "java:jboss/datasources/dice")
private DataSource dataSource;
我错过了@Resource 注释并使用名称而不是查找。 (切换 jndi 名称只是为了测试。以防万一)
【讨论】:
@mkuff 请你分享standalone.conf中的数据源配置以上是关于Wildfly 数据源与 DefaultDS 冲突的主要内容,如果未能解决你的问题,请参考以下文章
JBoss(Wildfly 10) Linux安装,端口冲突
JBoss(Wildfly 10) Linux安装,端口冲突
JBoss(Wildfly 10) Linux安装,端口冲突
JBoss(Wildfly 10) Linux安装,端口冲突