1 Reply Latest reply on Oct 3, 2012 1:04 AM by Srinivas Reddy Bijjam

    Deploying datasource via -ds.xml files in JBoss AS 7.1.1.Final

    Srinivas Reddy Bijjam Newbie

      Dear All

       

        I am getting the following error while looking up the datasource that was bounded by ds.xml file but it is working fine with the datasource that is defined in standalonefull.xml

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4) java.lang.ClassCastException: javax.naming.Reference cannot be cast to javax.sql.DataSource

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4)      at xxx.utils.DataSourceHelper.getDataSource(DataSourceHelper.java:31)

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4)      at java.lang.reflect.Method.invoke(Method.java:597)

      22:53:08,531 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.tx.EjbBMTInterceptor.handleInvocation(EjbBMTInterceptor.java:105)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.tx.BMTInterceptor.processInvocation(BMTInterceptor.java:56)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,546 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:80)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

      22:53:08,562 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.component.interceptors.EjbExceptionTransformingInterceptorFactories$1.processInvocation(EjbExceptionTransformingInterceptorFactories.java:65)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

      22:53:08,578 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:179)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:179)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:43)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)

      22:53:08,593 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)

      22:53:08,609 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)

      22:53:08,609 ERROR [stderr] (http--127.0.0.1-8080-4)      at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)

       

      java code to look up is

       

       


       
      Context ctx = new InitialContext();

       
      return (javax.sql.DataSource) ctx.lookup("java:/"+dsName);

       

       

      mydatasource-ds.xml

      <?xml version="1.0" encoding="UTF-8"?><datasources>

      <xa-datasource enabled="true" jndi-name="java:/mydatasource" pool-name="mydatasource" use-java-context="true">

      <xa-datasource-property name="URL">jdbc:oracle:thin:@localhost:1521:orcl</xa-datasource-property>

      <driver>ojdbc6</driver>

      <xa-pool>

      <min-pool-size>1</min-pool-size>

      <max-pool-size>20</max-pool-size>

      <prefill>true</prefill>

      <is-same-rm-override>false</is-same-rm-override>

      <no-tx-separate-pools>true</no-tx-separate-pools>

      </xa-pool>

      <security>

      <user-name>xxx</user-name>

      <password>xxx</password>

      </security>

      <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

      </xa-datasource>

      </datasources>

       

      standalonefull.xml content is

       

                  <datasources>

                      <xa-datasource jndi-name="java:/xxx-oraclePool" pool-name="xxx-oraclePool" enabled="true" use-java-context="true">

                          <xa-datasource-property name="URL">

                              jdbc:oracle:thin:@localhost:1521:orcl

                          </xa-datasource-property>

                          <driver>ojdbc6</driver>

                          <xa-pool>

                              <min-pool-size>1</min-pool-size>

                              <max-pool-size>20</max-pool-size>

                              <prefill>true</prefill>

                              <is-same-rm-override>false</is-same-rm-override>

                              <no-tx-separate-pools>true</no-tx-separate-pools>

                          </xa-pool>

                          <security>

                              <user-name>xxx</user-name>

                              <password>xxx</password>

                          </security>

                      </xa-datasource>

                      <drivers>

                          <driver name="ojdbc6" module="com.oracle.ojdbc6">

                              <driver-class>oracle.jdbc.OracleDriver</driver-class>

                              <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>

                          </driver>

                      </drivers>

                  </datasources>

       

      module.xml is

      <?xml version="1.0" encoding="UTF-8"?>

      <module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6">

        <resources>

          <resource-root path="ojdbc6.jar"/>

        </resources>

        <dependencies>

          <module name="javax.api"/>

          <module name="javax.transaction.api"/>

      </dependencies>

      </module>

       

      What is the reason it is throwing error for ds.xml but working fine for standalone-full.xml?