Oracle JDBC驱动程序冲突 [英] Oracle JDBC driver conflict

查看:237
本文介绍了Oracle JDBC驱动程序冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JBoss EAP 6.1 standlone服务器

JBoss EAP 6.1 standlone server

部署为war文件的应用程序抛出运行时异常

Application deployed as a war file throws a runtime exception

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

at line

oracle.sql.ARRAY obj = (oracle.sql.ARRAY) rs.getObject("RATINGOBJ");

包含的JDBC库是ojdbc6.jar(WEB_INF / lib)。所有库都包含在war文件中,并且服务器上没有设置全局库。我已经验证应用程序中的任何地方都没有包含其他jdbc库。

JDBC libary included is ojdbc6.jar (WEB_INF/lib). All libraries are included in the war file and there are no "global" libaries setup on the server. I have verified no other jdbc libraries are included anywhere in the app.

为了创建JDBC数据源,我为ojdbc6.jar创建了一个部署。这是我能想到的唯一可能的冲突根源。当我从war文件中删除ojdbc6.jar时,我得到一个ClassNotFound异常来代替ClassCastException。

In order to create a JDBC datasource, i created a deployment for ojdbc6.jar. This is the only possible source of conflict i can think of. When i remove the ojdbc6.jar from the war file, i get a ClassNotFound exception in place of the ClassCastException.

除了这一行,应用程序的每个其他部分都能正常工作。我如何进一步调试这个?

Every other part of the app works fine except this line. How do i debug this any further?

推荐答案

我不确定为什么从web-inf / lib加载不起作用。最有可能的是,类加载器是不同的。

I am not sure why loading from web-inf/lib will not work. Most likely the classloader's are different.

执行前两步诊断。之后尝试以下两种方法中的一种来解决问题。

1)通过比较 rs.getObject()来检查类加载器是否相同.getClass('RATINGOBJ ')。getClassLoader() oracle.sql.ARRAY.class.getClassLoader()
如果你做 equals 在两个类加载器之间,它应该返回false,因为它看起来类加载器是不同的。
查看
的解释投射到同一时间的ClassCastException class

Do the first two steps for diagnosis. After that try one of the two alternatives below to fix the problem.
1) Check if the class loaders are the same by comparing the rs.getObject().getClass('RATINGOBJ').getClassLoader() and oracle.sql.ARRAY.class.getClassLoader() If you do equals between the two classloaders, it should return false as it looks that the classloaders are different. Check an explanation at ClassCastException when casting to the same class

此问题已在之前的另一个论坛中报告过 https://forums.oracle.com/message/9330314 。在jboss中移动jars仍然会导致相同的问题。

This problem has already been reported earlier in another forum at https://forums.oracle.com/message/9330314. Moving jars around in jboss will still result in same problems.

2)找出从哪里加载类的源jar并删除你不需要的jar。
通过检查

rs.getObject()。getClass('RATINGOBJ')。getProtectionDomain()。getCodeSource()。getLocation(找到两个不同类的罐子) )
oracle.sql.ARRAY.class.getProtectionDomain()。getCodeSource()。getLocation()
- < a href =https://stackoverflow.com/questions/1983839/determine-which-jar-file-a-class-is-from>确定一个类来自哪个JAR文件

2) Find out the source jars from where the classes are getting loaded and remove the jar that you dont need. Find the jars for the two different classes by checking
rs.getObject().getClass('RATINGOBJ').getProtectionDomain().getCodeSource().getLocation() oracle.sql.ARRAY.class.getProtectionDomain().getCodeSource().getLocation() - Determine which JAR file a class is from

可能的解决方案:

a)如果你需要两个罐子,你必须移动
的瓶子 rs.getObject()。getClass('RATINGOBJ')。getProtectionDomain()。getCodeSource()。getLocation()

a) If you need both the jars, y'll have to move the Jar of rs.getObject().getClass('RATINGOBJ').getProtectionDomain().getCodeSource().getLocation()

并创建 http://www.javaworld.com/community/node中指定的模块/ 8184

b)如果仍然无法按预期加载类,请在jboss服务器库中指定库。

b) If you still cant get classes to be loaded as you expect, Specify the library in jboss server library.

c)最后的解决方案要从特定jar加载的强制类是通过在bootclasspath中指定jar。

c) The last solution to force classes to be loaded from a particular jar is by specifying the jar in the bootclasspath.

这篇关于Oracle JDBC驱动程序冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆