2013-10-24 45 views
0

我工作的項目,必須在兩個weblogic的JBoss的部署。我從源頭上編譯了wildfly。現在,我正在嘗試使用命名來獲取數據源。應用是JBOSS EAP 6.1做工精細,我能夠得到的數據源引用作爲javax.sql.DataSource但是現在widlfly,使用下面的代碼context.lookup(「數據源」)返回org.jboss.jca.adapters.jdbc.WrapperDataSource

dataSource = (javax.sql.DataSource) context.lookup("datasource"); 

它拋出異常

 
java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.WrapperDataSource cannot be cast to javax.sql.DataSource 
如果我嘗試

使用以下代碼,

Object obj = context.lookup("datasource"); 
dataSource = (javax.sql.DataSource) obj; 

它不會拋出例外,而使用的數據源上面,它會拋出異常

 
Caused by: java.lang.IncompatibleClassChangeError: Class org.jboss.jca.adapters.jdbc.WrapperDataSource does not implement the requested interface javax.sql.DataSource 

然而,看着類的代碼,我們可以看到,它實現了javax.sql.DataSource

誰能告訴我怎麼可以使用鑄造WrapperDataSource或者將數據源返回爲javax.sql.DataSource

服務器信息:

 
Calling "C:\wildfly-8.0.0.Beta2-SNAPSHOT\bin\standalone.conf.bat" 
Setting JAVA property to "C:\Progra~2\Java\jdk1.7.0_40\bin\java" 
=============================================================================== 

    JBoss Bootstrap Environment 

    JBOSS_HOME: "C:\wildfly-8.0.0.Beta2-SNAPSHOT" 

    JAVA: "C:\Progra~2\Java\jdk1.7.0_40\bin\java" 

=============================================================================== 

Listening for transport dt_socket at address: 8787 
16:04:19,731 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final 
16:04:19,903 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.0.Beta2 
16:04:19,997 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.0.0.Beta2-SNAPSHOT "WildFly" starting 
16:04:21,138 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) 
16:04:21,138 INFO [org.xnio] (MSC service thread 1-1) XNIO version 3.1.0.CR7 
16:04:21,153 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.1.0.CR7 
16:04:21,309 INFO [org.jboss.remoting] (MSC service thread 1-1) JBoss Remoting version 4.0.0.Beta1 
16:04:21,341 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 50) JBAS015537: Activating WebServices Extension 
16:04:21,356 INFO [org.jboss.as.security] (ServerService Thread Pool -- 46) JBAS013171: Activating Security Subsystem 
16:04:21,372 INFO [org.jboss.as.security] (MSC service thread 1-8) JBAS013170: Current PicketBox version=4.0.19.Final 
16:04:21,388 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 41) JBAS011800: Activating Naming Subsystem 
16:04:21,388 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 33) JBAS010280: Activating Infinispan subsystem. 
16:04:21,388 INFO [org.wildfly.extension.undertow] (MSC service thread 1-3) JBAS017502: Undertow 1.0.0.Beta18 starting 
16:04:21,403 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017502: Undertow 1.0.0.Beta18 starting 
16:04:21,403 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 39) JBAS012605: Activated the following JSF Implementations: [main] 
16:04:21,419 INFO [org.jboss.as.connector.logging] (MSC service thread 1-7) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.0.Final) 
16:04:21,450 INFO [org.jboss.as.naming] (MSC service thread 1-3) JBAS011802: Starting Naming Service 
16:04:21,466 INFO [org.jboss.as.mail.extension] (MSC service thread 1-7) JBAS015400: Bound mail session [java:jboss/mail/Default] 
16:04:21,466 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 
16:04:21,481 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010417: Started Driver service with driver-name = h2 
16:04:21,559 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017527: Creating file handler for path C:\wildfly-8.0.0.Beta2-SNAPSHOT/welcome-content 
16:04:21,700 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017525: Started server default-server. 
16:04:21,700 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017531: Host default-host starting 
16:04:21,763 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080 
16:04:21,841 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class com.ibm.db2.jcc.DB2Driver (version 3.57) 
16:04:21,841 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010417: Started Driver service with driver-name = DB2Driver 
16:04:22,091 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) JBAS015012: Started FileSystemDeploymentService for directory C:\wildfly-8.0.0.Beta2-SNAPSHOT\standalone\deployments 
16:04:22,091 INFO [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on 127.0.0.1:9999 
16:04:22,122 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.1.Final 
16:04:22,122 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 
16:04:22,122 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:/rapiddb] 
16:04:22,247 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management 
16:04:22,247 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 
16:04:22,247 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Beta2-SNAPSHOT "WildFly" started in 2828ms - Started 186 of 223 services (62 services are lazy, passive or on-demand) 

回答

2

我相信它會是與你的服務器上配置JDBC驅動程序在數據源或方式,如果你提供你的包裝的另一個驅動程序,使得與碰撞您使用的實際驅動程序。

類似的錯誤可以在https://community.jboss.org/message/250795

發現如果不解決也張貼在其中所遇到的問題的服務器版本。只是爲了確保您不會受到服務器上固定數據源修補程序的困擾。

+0

翻轉您好,感謝您的答覆,我有** DB2驅動程序**配置爲靜態模塊**下**模塊目錄。我檢查並找不到其他任何** db2jcc.jar **&** db2jcc_license_cu.jar **的副本。 –

+0

我已經將應用程序部署爲EAR,並且相同的應用程序在JBOSS EAP 6.1上正常工作。哪個其他驅動程序可能與DB2驅動程序有衝突? –

1

我在WildFly論壇(WildFly Thread)上發佈了這個問題,發現還有另一個包含javax.sql.DataSource接口的jar。

我使用了一個名爲jarscan.jar組件來搜索界面在我的模塊,發現一個罐子中含有另一種javax.sql.DataSource類。刪除jar表單模塊解決了這個問題。