6 Replies Latest reply on Jan 31, 2007 5:18 PM by davidoff

    Oracle Connection -- WrappedConnection -- CastException

    davidoff

      Hello colleagues,

      I am sure someone bumped into this once before.

      I am trying to get an OracleConnection from Jboss pool manager and JNDI.

      My understanding is to get a WrappedConnection from the JNDI DataSource, I am still getting a CastException. I was wondering what is the solution around this CastException, this is the code I am using:

      con = ds.getConnection();
      WrappedConnection wc = (WrappedConnection) con;
      OracleConnection ora_con = (OracleConnection)wc.getUnderlyingConnection();


      Thanks.

        • 1. Re: Oracle Connection -- WrappedConnection -- CastException
          weston.price

          This usually occurs when you have either multiple oracle jar files (for example one in the server/lib directory and one in your EAR/WAR). Can you verify that you only have one copy of the driver?

          The other reason is that you are attempting to use the DS outside of JBoss (ie remote client). Can you post your *-ds.xml file?

          • 2. Re: Oracle Connection -- WrappedConnection -- CastException
            davidoff


            Hi,

            I verified there is no conflict in classloading the driver, I have one driver(10g) in the application lib.

            This is my ds.xml, Thanks!




            <xa-datasource>
            <jndi-name>XAOracleDS</jndi-name>
            <track-connection-by-tx/>
            <isSameRM-override-value>false</isSameRM-override-value>
            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
            <xa-datasource-property name="URL">jdbc:oracle:thin:@x.x.x.x:1521:x</xa-datasource-property>
            <xa-datasource-property name="User">x</xa-datasource-property>
            <xa-datasource-property name="Password">x</xa-datasource-property>
            <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
            <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
            <!-- Checks the Oracle error codes and messages for fatal errors -->
            <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
            <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
            <no-tx-separate-pools/>

            <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

            <type-mapping>Oracle9i</type-mapping>

            </xa-datasource>


            <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager


            • 3. Re: Oracle Connection -- WrappedConnection -- CastException
              weston.price

              When you say application lib, I assume you mean your deployment archive right, or do you mean in your server/lib directory? The reason I ask is that there are significant Classloader issues when attempting to include your JDBC driver inside of your EAR/WAR etc.

              • 4. Re: Oracle Connection -- WrappedConnection -- CastException
                davidoff

                In the WEB-INF/LIB of the war file, the SERVER(Default)/LIB has no driver.

                Thanks,
                Dvdoff

                • 5. Re: Oracle Connection -- WrappedConnection -- CastException
                  weston.price

                  Yep. There's the issue.

                  We discourage putting the driver in the EAR/WAR/lib directory for this very reason. Unfortunately, the JDBC DriverManager, as well as most XADataSource implementations have significant classloader caching/loading issues that make inclusion of the drivers in the deployment modules difficult.

                  Similarly, because WAR files have their own classloading architecture, independent of the JBoss ClassLoader, you are seeing a ClassClassException. Easiest thing to do is put the JDBC jar file in your server/lib directory.

                  • 6. Re: Oracle Connection -- WrappedConnection -- CastException
                    davidoff

                    Sorry to be a pain, so far, no luck, even with the driver on the server/lib and no driver in the deployment file, same CastException. Could it be a bug in 10g driver ?

                    Please respond whenever you have time. Appreciated!