Oracle JDBC Driver Conflict

Separate JBoss EAP 6.1 Server

An application deployed as a war file throws a run-time exception

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

in line

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

JDBC libary includes ojdbc6.jar (WEB_INF / lib). All libraries are included in the war file, and there are no "global" libaries sets on the server. I have confirmed that no other jdbc libraries are included anywhere in the application.

To create a JDBC data source, I created a deployment for ojdbc6.jar. This is the only possible source of conflict that I can think of. When I remove ojdbc6.jar from the war file, I get a ClassNotFound exception instead of a ClassCastException.

Every other part of the application works fine except for this line. How do I debug this further?

+4
source share
2 answers

I'm not sure why loading from web-inf / lib will not work. Most likely, the cool bootloader is different.

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

This issue has already been reported earlier on another forum at https://forums.oracle.com/message/9330314 . Moving banners to jboss will still lead to the same problems.

2) Find out the source banks from which classes are loaded, and delete the bank that you do not need. Find banks for two different classes by checking rs.getObject().getClass('RATINGOBJ').getProtectionDomain().getCodeSource().getLocation() oracle.sql.ARRAY.class.getProtectionDomain().getCodeSource().getLocation() - Determine from which JAR file the class belongs

Possible solutions:

a) If you need both banks, you will have to move the bank rs.getObject().getClass('RATINGOBJ').getProtectionDomain().getCodeSource().getLocation()

and create the module listed at http://www.javaworld.com/community/node/8184 .

b) If you still cannot load the classes as you expect, specify the library in the jboss server library.

c) The final solution for forcing classes to be loaded from a specific bank is to specify a jar in the bootclasspath.

+2
source

You should not have JDBC JAR drivers at the WEB-INF / lib level. Java EE application servers need to be at the application server level.

Move it to the default directory for the / lib server and see if it is better.

+3
source

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


All Articles