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 typ
What's happening here is that JBoss wraps the oracle connection (oracle.jdbc.OracleConnection) with it's own one (org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6). You have to call #getUnderlyingConnection() to get the underlying connection.
WrappedConnection wrapped = (WrappedConnection) conn;
CLOB clob = CLOB.createTemporary(wrapped.getUnderlyingConnection(), true, CLOB.DURATION_SESSION);
However I ask myself whether the following wouldn't work as well in your case.
ps.setClob(4, new StringReader(data));
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)
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.
Got a similar problem in a Rails App with Jruby 1.7.2, JBoss 7.1 and Oracle (oracle_enhanced adapter)
Java::JavaLang::ClassCastException: oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection
This solution worked for me.
I put the jboss-deployment-structure.xml in the config/ directory of the rails app and updated the warbler config to include the file in the war file:
config.webinf_files += FileList["config/jboss-deployment-structure.xml"]
After deploy all worked fine ... Thx a lot.