Java.lang.ClassCastException: oracle.sql.CLOB cannot be passed to oracle.sql.CLOB

I recently updated the launch app using JAVA 7 and JBoss 7.1.1. This app was originally developed on JAVA 5 and Jboss 4.2.2. This app uses hibernate 3 to save.

On the new platform, the application does not work when there is an INSERT attempt to a table with CLOB fields with the above error. I am using ojdbc14.jar (Oracle Database Database 10.2.0.3)

These are the things I checked in jboss 7.1.1 configuration:

  • Creating the right module for Oracle. Make sure ojdbc14.jar exists in the correct modules directory
  • Make sure there is no other conflicting ojdbc.jar file that exists elsewhere in the jboss directory
  • Make sure the application does not reference another ojdbc.jar file.

Any insight would be helpful. I pull my hair, trying to solve this problem for almost a week.

thanks a lot

+4
source share
2 answers

I fixed the problem. Pursuing this answer, hoping that this might be useful to someone.

When I checked the type of the CLOB instance retrieved by request, it appeared as oracle.sql.CLOB. Therefore, I assumed that this should have been a mismatch of the ojdbc.jar version. I checked my project gazillion times for several copies of ojdb.jar. There were none.

Finally, it turned out to be a clash between sleeping and ojdbc. I changed the link to java.sql.Clob. Hibernate uses java.sql.Clob. This resolved the issue.

+5
source

In my situation, I do not use Hibernate, but I use Jboss as a container and I had to remove the oracle module from jboss-deployment-structure.xml so I could no longer use oracle.sql.CLOB and I had the same probe

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

in the end i used

  java.sql.Clob clobValue = (java.sql.Clob)result.getClob("EMIRFILE"); 

and it works correctly. I hope this helps someone.

0
source

Source: https://habr.com/ru/post/1487138/


All Articles