Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB

I recently upgraded an application to run using JAVA 7 and JBoss 7.1.1 This application was originally developed on JAVA 5 and Jboss 4.2.2. This application uses hibernate 3 for persistence.

On the new platform, the application is failing when there is an attempt to INSERT into a table with CLOB fields with the above error. I am using ojdbc14.jar (backend database Oracle 10.2.0.3)

These are things that I have verified in jboss 7.1.1 configuration:

  1. Creation of the correct module for Oracle. Ensured that ojdbc14.jar exists in the correct modules directory
  2. Ensured that there are no other conflicting ojdbc.jar existing anywhere else in the jboss directory
  3. Ensured that the application is not referring to a different ojdbc.jar.

Any insight would be helpful. I am pulling my hair trying to resolve this issue for almost a week now.

Thanks much

like image 521
user1807337 Avatar asked Jun 19 '13 20:06

user1807337


1 Answers

I fixed the problem. Posting this answer, hoping it might be useful to someone.

When I was checking the instance type of the CLOB retrieved by the query, it came up as oracle.sql.CLOB. So I assumed it must have been a version mismatch of ojdbc.jar. I checked my project a gazillion times for multiple copies of the ojdb.jar. There were none.

Finally it turned out to be a clash between hibernate and ojdbc. I changed the reference to java.sql.Clob. Hibernate uses java.sql.Clob. This resolved the problem.

like image 198
user1807337 Avatar answered Nov 02 '22 07:11

user1807337