1

I'm working to migrate an application from Oracle Application Server to JBoss EAP 6.1. I have most things working but I am getting one error that I haven't been able to figure out:

13:27:29,743 ERROR [com.myproj.db.dao.myDao] (Thread-164) Get Prepared Statement: 
java.lang.ClassCastException: 
org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 cannot be cast
to oracle.jdbc.internal.OraclePreparedStatement

I have Oracle set up as a module in JBoss for connection pooling using ojdbc6.jar (and it works for other parts of the application), but for the one part of the application that uses an OraclePreparedStatement, it gets the error.

I did make certain that there is no ojdbc6.jar file in the WAR file. The only one in JBoss seems to be inside of the module.

I did try changing the OraclePreparedStatement class to oracle.jdbc.OraclePreparedStatement, but the results are the same.

I did try running with TRACE on for logging to see where classes were loading from. OraclePreparedStatement was loaded from the module with the exception of this line:

4:31:40,583 TRACE [org.jboss.modules] (Thread-84) Finding class 
oracle.jdbc.OraclePreparedStatement from Module "deployment.myProj.war:main" from
Service Module Loader

Here's a link to an excerpt of the log - basically just the lines related to OraclePreparedStatement.

I have confirmed that there is no ojdbc6.jar (or any Oracle related jars) in the WAR file, and there is no OraclePreparedStatement class inside of the WAR file either.

I do have the module listed as a dependency in my JBoss deployment structure xml file.

Anyone have any ideas?

Ruminator
  • 129
  • 3
  • 13
  • I assume you are using Oracle specific extensions that mean you need to cast to OraclePreparedStatement? – Mark Jan 13 '14 at 21:26
  • @Mark, Yes. The code is casting a `PreparedStatement` to an `OraclePreparedStatement` so that it can . As I am simply trying to move an old project (that I didn't write) from Oracle Application Server to JBoss, I don't really want to have to rewrite the class file. – Ruminator Jan 14 '14 at 02:27
  • From a quick look at the javadoc try first casting to `org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6` then call `getUnderlyingStatement` and try to cast that object to `oracle.jdbc.internal.OraclePreparedStatement`. – Mark Jan 14 '14 at 09:25
  • @Mark - that seemed to work. ` if (a instanceof WrappedPreparedStatementJDK6) { WrappedPreparedStatementJDK6 b = (WrappedPreparedStatementJDK6) a; stmt = (OraclePreparedStatement) b.getUnderlyingStatement(); } else { stmt = (OraclePreparedStatement) a; }` If you want to write of an official answer, I will mark it as accepted for you. – Ruminator Jan 14 '14 at 22:47

1 Answers1

1

From looking at the javadoc I would guess that org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 is wrapping the underlying Oracle JDBC driver.

org.jboss.jca.adapters.jdbc.jdk6.WrappedPreparedStatementJDK6 has a method to get the underlying statement. Perhaps you should try something like the following:

WrappedPreparedStatementJDK6 statement = ...
OraclePreparedStatement oracleStatement = (OraclePreparedStatement)statement.getUnderlyingStatement();
Mark
  • 28,783
  • 8
  • 63
  • 92