簡體   English   中英

Wildfly數據源與DefaultDS沖突

[英]Wildfly Datasource conflicting with DefaultDS

我從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部署了我的骰子數據源並將其綁定到[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名稱它是有效的(例如骰子),但我不明白為什么。 我究竟做錯了什么?

問候,m

@Resource(lookup = "java:jboss/datasources/dice")
private DataSource dataSource;

我錯過了使用@Resource注釋並使用名稱而不是查找。 (切換jndi名稱只是為了測試。如果你想知道)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM