jdbcjbossconnectionclasscastexceptionjboss6.x

java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6


I have the following problem:

java.lang.ClassCastException: org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be cast

I did try to add the ironjacamar-jdbc-1.0.17.Final-redhat-1.jar in the project-tree under lib.

When I deploy the project I get the following exception:

org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6 cannot be to org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6

The code where the exception occurs:

java.sql.Connection connection =  ds.getConnection();
WrappedConnection c =  ((WrappedConnection)connection).getUnderlyingConnection();
OracleConnection conn = (OracleConnection) c;

I did add a new file, jboss-deployment-structure.xml, with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure> 
    <deployment>
        <dependencies>
            <module name="org.jboss.ironjacamar.jdbcadapters" slot="main"/>
            <module name="com.oracle.ojdbc6" slot="main"/>
        </dependencies>
    </deployment> 
</jboss-deployment-structure>

In this case i get:

moduleloading error can not load 

<module name="com.oracle.ojdbc6" slot="main"/

Manifest.MF:

Manifest-Version: 1.0
Class-Path: 
Dependencies:  org.jboss.ironjacamar.jdbcadapters

Removing

<module name="com.oracle.ojdbc6" slot="main"/>

I get

oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection

It want cast everything to everything JBoss kidding me ?

Can you tell me what I have to do in order to get an OracleDamnedConnection ?


Solution

  • in the file jboss-deployement-structure.xml

    you i had to write:

     <?xml version="1.0" encoding="UTF-8"?>
     <jboss-deployment-structure> 
     <deployment>
     <dependencies>
     <module name="org.jboss.ironjacamar.jdbcadapters" slot="main"/>
     <module name="com.oracle" />
    
     </dependencies>
    
     </deployment> 
     </jboss-deployment-structure>
    

    because it has to match the path of the jar ojdbc, last folder was Main. and it looks inside Main. so i had the path /com/oracle/main/ojdbc.jar