Java Wildfly数据源与DefaultDS冲突

Java Wildfly数据源与DefaultDS冲突,java,jakarta-ee,wildfly,Java,Jakarta Ee,Wildfly,我从JBoss7.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: U

我从JBoss7.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>
在启动方法中,我只做如下操作:

        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),但我不明白为什么。我做错了什么

您好, m


我错误地使用了@Resource注释,使用了name而不是lookup。(切换jndi名称只是为了测试。如果你想知道的话)

你不需要把整个名称放在``标记中吗?你是说java:/jdbc/dice吗?尝试过了,但我得到了:JBAS011053:java:/jdbc/dice-source:lookup(java:comp/DefaultDataSource)上的不兼容冲突绑定得到了它。谢谢你的努力,圣堂武士!在下面发布答案。@mkuff请在standalone.conf中共享数据源配置
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"
@Resource(lookup = "java:jboss/datasources/dice")
private DataSource dataSource;