Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Application Version: JBoss 7.0.0, Oracle 11g (ojdbc6.jar) and JDK 6 version

I have a problem when I am trying to insert the value for CLOB Data type using CLOB.createTemporary function, getting the below exception.

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

After searching in multiple forums, did not find any solution. https://forums.oracle.com/forums/thread.jspa?threadID=279238

Basic steps required to deploy a WAR file and configuring the JBoss oracle driver pool configuration is done. But, still not able to get through this issue.

Please provide solution to fix this problem.

like image 545
Rajkumar Avatar asked Apr 20 '12 13:04

Rajkumar


1 Answers

I have solved my problem with the below approach.

Summary: Class loader should not load the Oracle driver from server lib/modules and in web archive (WAR file). Keep the oracle driver only in server lib (JBoss 7 ver).

JBoss 7:

  • Created a new JBoss deployment descriptor file(jboss-deployment-structure.xml)

    1. Updated the (ironjacamar-jdbc-1.0.3.Final.jar) iron module in the jboss deployment structure file
    2. Created the ojdbc6.jar as module in the JBoss 7 structure Updated the objbc module in the jboss deployment structure file
    3. Example:

      <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>
      

Web module: - Removed the ojdbc6.jar file from the web archive(WAR file)

If you find any issue in solving, please let me know.

like image 196
Rajkumar Avatar answered Sep 29 '22 17:09

Rajkumar