1 Reply Latest reply on Aug 18, 2006 3:17 PM by Jonathan Newbrough

    Oracle Data Source ClassCastException when getting XA Connec

    kalichar Newbie

      I have the following configuration defined in oracle-ds.xml and the file is correclty deployed.

      <local-tx-datasource>
       <jndi-name>jdbc/SimpleDataSource</jndi-name>
       <driver-class>oracle.jdbc.xa.client.OracleXADataSource</driver-class>
       <connection-url>jdbc:connection:thin:@localhost:1521:oracle</connection-url>
       <user-name>scott</user-name>
       <password>tiger</password>
       <valid-connection-checker-class-name>
       org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       </local-tx-datasource>
      


      I have the new oracle driver library installed in the correct place.
      When I try to obtain a connection, I get the following ClassCastException:

      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: oracle.jdbc.xa.client.OracleXADataSource; - nested throwable: (java.lang.ClassCastException))
       at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:160)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:477)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:213)
       at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:496)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:425)
       at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:318)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:477)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)
      

      This occurs when I do the following:
      InitialContext context = new InitialContext();
      DataSource ds = (DataSource) context.lookup ( "java:jdbc/SimpleDataSource");
      Connection conn = ds.getConnection();
      
      


      I am clueless as to why there is a class cast exception here. The code is being run within the JBoss VM. Please assist . Thanks in advance.

        • 1. Re: Oracle Data Source ClassCastException when getting XA Co
          Jonathan Newbrough Newbie

          For what its worth (your post is 2 years old now, but I found it on a search so maybe someone else will find it as well...)

          I am having the same problem with jboss 4.0.3. My code is almost identical -- lookup, get datasource, then ClassCastException on ds.getConnection(). My exception says "ClassCastException: com.inet.tds.TdsDriver" (the name of my JDBC driver).

          However, I have created two datasources that use the same driver, but one is an XA connection and the other is not. The non-XA connection was created by modifying the jboss-4.0.3/examples/jca/mssql-ds.xml and this one works fine. The XA connection was created by modifying examples/jca/mssql-xa-ds.xml and this one gives the problem.

          So I think the problem has to do with the classloading context of the connection pools in JBoss. From the XML code above, looks like the original poster also was using an XA datasource and got the same error.