6 Replies Latest reply on Oct 25, 2013 2:58 AM by nabeel.bukhari

    Wildfly Datasource ClassCastException

    nabeel.bukhari

      I am working on project which needs to be deployable on both weblogic and jboss. I have compiled WildFly Beta 2 from sources. Now, I am trying to get datasource using naming. In JBOSS EAP 6.1, I was able to get datasource instancce casted as javax.sql.DataSource, but now it if I try to cast the WrapperDataSource to javax.sql.DataSource as following:

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

      , it throws

      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

      What else configuration is required to use casted WrapperDataSource or get datasource returned as javax.sql.DataSource.


        • 1. Re: Wildfly Datasource ClassCastException
          lafr

          javax.sql.DataSource is part of Java runtime.

          Do you have something in your deployments unit which brings in another version of this interface?

          • 2. Re: Wildfly Datasource ClassCastException
            nabeel.bukhari

            Hi Frank

             

            Thanks for responding, I have multiple jdks installed but JAVA_HOME is set to C:\Progra~2\Java\jdk1.7.0_40\bin\java and WildFly is running using same JDK.

             

            Here are the logs from server:

             

            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"

             

             

              JAVA_OPTS: "-client -Dprogram.name=standalone.bat -Xms503M -Xmx1303M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n -Djboss.bind.address=localhost -Djboss.bind.address.management=localhost"

             

             

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

             

             

            Listening for transport dt_socket at address: 8787

            19:25:02,912 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.0.Final

            19:25:03,084 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.0.Beta2

            19:25:03,162 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.0.0.Beta2-SNAPSHOT "WildFly" starting

            19:25:04,303 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)

            19:25:04,318 INFO  [org.xnio] (MSC service thread 1-6) XNIO version 3.1.0.CR7

            19:25:04,318 INFO  [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.1.0.CR7

            19:25:04,443 INFO  [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version 4.0.0.Beta1

            19:25:04,459 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 33) JBAS010280: Activating Infinispan subsystem.

            19:25:04,459 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 46) JBAS013171: Activating Security Subsystem

            19:25:04,475 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 50) JBAS015537: Activating WebServices Extension

            19:25:04,490 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 41) JBAS011800: Activating Naming Subsystem

            19:25:04,506 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 39) JBAS012605: Activated the following JSF Implementations: [main]

            19:25:04,506 INFO  [org.jboss.as.security] (MSC service thread 1-4) JBAS013170: Current PicketBox version=4.0.19.Final

            19:25:04,506 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-8) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.0.Final)

            19:25:04,521 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 28) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

            19:25:04,537 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) JBAS010417: Started Driver service with driver-name = h2

            19:25:04,584 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service

            19:25:04,584 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]

            19:25:04,584 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS017502: Undertow 1.0.0.Beta18 starting

            19:25:04,600 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017502: Undertow 1.0.0.Beta18 starting

            19:25:04,834 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 49) JBAS017527: Creating file handler for path C:\wildfly-8.0.0.Beta2-SNAPSHOT/welcome-content

            19:25:04,834 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017525: Started server default-server.

            19:25:04,850 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017531: Host default-host starting

            19:25:04,881 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)

            19:25:04,896 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010417: Started Driver service with driver-name = DB2Driver

            19:25:04,943 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080

            19:25:05,162 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory C:\wildfly-8.0.0.Beta2-SNAPSHOT\standalone\deployments

            19:25:05,193 INFO  [org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on 127.0.0.1:9999

            19:25:05,225 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

            19:25:05,225 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:/rapiddb]

            19:25:05,256 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.1.Final

            19:25:05,365 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management

            19:25:05,365 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990

            19:25:05,381 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Beta2-SNAPSHOT "WildFly" started in 2765ms - Started 186 of 223 services (62 services are lazy, passive or on-demand)

             

            I have configured DB2 driver as static module under modules directory. It doesn't seem to confilct with any other.

             

            One more thing, if I debug using eclipse and try to inspect on the code it doesn't throw any exception but if I try to step-on then it throws exception. This behaviour is really strange

            • 3. Re: Wildfly Datasource ClassCastException
              ctomc

              I think just your lookup is wrong.

               

              try looking up "java:/rapiddb"

               

              you can also inject datasource by doing

               

              @Resource(lookup="java:/rapiddb")

              DataSource datasource;

              1 of 1 people found this helpful
              • 4. Re: Wildfly Datasource ClassCastException
                nabeel.bukhari

                Hi Tomaz,

                 

                I am trying to lookup like context.lookup(filedata[5]); where filedata is an array and containing some parameters. I wrote it as context.lookup("datasource"); for simplicity. I cannot use @Resource as the above class is not a bean. Its a singletion class working on native sql.

                • 5. Re: Wildfly Datasource ClassCastException
                  nabeel.bukhari

                  Tomaz Cerar wrote:

                   

                  I think just your lookup is wrong.

                   

                  try looking up "java:/rapiddb"

                   

                  you can also inject datasource by doing

                   

                  @Resource(lookup="java:/rapiddb")

                  DataSource datasource;

                  I created a singleton bean and injected datasource by doing

                   

                  @Resource(lookup="java:/rapiddb")

                  DataSource datasource;

                   

                  when trying to get datasource using getter, I found the following exception seems to be same.

                   

                  11:17:58,211 ERROR [org.jboss.as.ejb3.invocation] (ServerService Thread Pool -- 92) JBAS014134: EJB Invocation failed on component DataSourceManager for method public javax.sql.DataSource ejb.helper.session.DataSourceManager.getDatasource(): javax.ejb.EJBTransactionRolledbackException: JBAS011048: Failed to construct component instance

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.invocationmetrics.WaitTimeInterceptor.processInvocation(WaitTimeInterceptor.java:43) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:325)

                          at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:437)

                          at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:325)

                          at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                          at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

                          at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                          at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

                          at ejb.helper.session.DataSourceManager$$$view616.getDatasource(Unknown Source) [HelperEJB.jar:]

                          at ejb.nativesql.session.RunNativeSQL.<init>(RunNativeSQL.java:121) [NativeEJB.jar:]

                          at ejb.nativesql.session.RunNativeSQL.getObject(RunNativeSQL.java:94) [NativeEJB.jar:]

                          at ejb.nativesql.session.dynamic.DataServiceProvider.init(DataServiceProvider.java:43) [NativeEJB.jar:]

                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_40]

                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_40]

                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_40]

                          at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_40]

                          at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptorFactory$ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptorFactory.java:130)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:165) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:148) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:406)

                          at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55) [weld-core-impl-2.1.0.CR1.jar:2013-09-26 16:53]

                          at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:84) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:56) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:115)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:62) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:369) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:325)

                          at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                          at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160)

                          at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:84)

                          at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:126) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:141) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)

                          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_40]

                          at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_40]

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]

                          at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]

                          at org.jboss.threads.JBossThread.run(JBossThread.java:122)

                  Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance

                          at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:162)

                          at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:84)

                          at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:126) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.component.singleton.SingletonComponentInstanceAssociationInterceptor.processInvocation(SingletonComponentInstanceAssociationInterceptor.java:47) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:251) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          ... 90 more

                  Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: Can not set javax.sql.DataSource field ejb.helper.session.DataSourceManager.datasource to org.jboss.jca.adapters.jdbc.WrapperDataSource

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:190) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:364) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43) [wildfly-weld-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.security.SecurityContextInterceptor.processInvocation(SecurityContextInterceptor.java:95) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [wildfly-ejb3-8.0.0.Beta2-SNAPSHOT.jar:8.0.0.Beta2-SNAPSHOT]

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:325)

                          at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)

                          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

                          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

                          at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160)

                          ... 95 more

                  Caused by: java.lang.IllegalArgumentException: Can not set javax.sql.DataSource field ejb.helper.session.DataSourceManager.datasource to org.jboss.jca.adapters.jdbc.WrapperDataSource

                          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [rt.jar:1.7.0_40]

                          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [rt.jar:1.7.0_40]

                          at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.7.0_40]

                          at java.lang.reflect.Field.set(Field.java:741) [rt.jar:1.7.0_40]

                       

                  @Frank:

                  Is there any way to find if I have multiple version of interface?

                  • 6. Re: Wildfly Datasource ClassCastException
                    nabeel.bukhari

                    YES, there was another jar part of my modules containing javax.sql.DataSource in it. Removing the jar name from module.xml fixed the issue.

                     

                    Thanks everyone for helping