java.lang.ClassCastException:oracle.sql.CLOB不能转换为oracle.sql.CLOB [英] java.lang.ClassCastException: oracle.sql.CLOB cannot be cast to oracle.sql.CLOB
问题描述
我最近升级了一个应用程序以使用JAVA 7和JBoss 7.1.1运行此应用程序最初是在JAVA 5和Jboss 4.2.2上开发的。此应用程序使用hibernate 3来进行持久化。
在新平台上,如果尝试将INSERT插入具有上述错误的CLOB字段的表中,则应用程序失败。我使用的是ojdbc14.jar(后端数据库Oracle 10.2.0.3)
这些是我在jboss 7.1.1配置中验证过的内容:
- 为Oracle创建正确的模块。确保ojdbc14.jar存在于正确的模块目录中
- 确保jboss目录中其他地方没有其他冲突的ojdbc.jar
- 确保应用程序不引用不同的ojdbc.jar。
任何见解都会有所帮助。
非常感谢
我修正了这个问题。发布此答案,希望对某人有用。
当我检查查询检索到的CLOB的实例类型时,它以oracle.sql的形式出现。 CLOB。所以我认为它一定是ojdbc.jar的版本不匹配。我检查了我的项目一个gazillion次ojdb.jar的多个副本。没有。
最后竟然是hibernate和ojdbc之间的冲突。我将引用更改为java.sql.Clob。 Hibernate使用java.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:
- Creation of the correct module for Oracle. Ensured that ojdbc14.jar exists in the correct modules directory
- Ensured that there are no other conflicting ojdbc.jar existing anywhere else in the jboss directory
- 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
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.
这篇关于java.lang.ClassCastException:oracle.sql.CLOB不能转换为oracle.sql.CLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!