I am working on project which needs to be deployable on both weblogic and jboss. I have compiled wildfly from sources. Now, I am trying to get datasource using naming. Application is working fine on JBOSS EAP 6.1, I am able to get datasource reference as javax.sql.DataSource
but now in widlfly, using following code
dataSource = (javax.sql.DataSource) context.lookup("datasource");
it throws exception
java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.WrapperDataSource cannot be cast to javax.sql.DataSource
if I try using following code,
Object obj = context.lookup("datasource");
dataSource = (javax.sql.DataSource) obj;
it doesn't throw the above exception rather on using the datasource, it throws exception
Caused by: java.lang.IncompatibleClassChangeError: Class org.jboss.jca.adapters.jdbc.WrapperDataSource does not implement the requested interface javax.sql.DataSource
However, looking at code of class, we can see that it implements the javax.sql.DataSource
Can anyone please tell me how can I use the casted WrapperDataSource
or get datasource returned as javax.sql.DataSource
.
Server Info:
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)