views:

2334

answers:

4

We have a web application that can be deployed on many application servers, including Oracle 10g. On that platform, however, we are having classpath issues. The webapp uses JAXB 2, but Oracle 10g ships with JAXB 1, and this was causing errors. To get around those we configured Oracle to prefer classes in our webapp, but now we are getting the above error when attempting to instantiate a JAXB context.

Looking up the "loader constraints violated" exception - it seems to be thrown when a class that has been loaded with one classloader attempts to access something that is package private in the same package but loaded by a different classloader. I have tried removing any jars in our webapp that include javax.xml.namespace.QName, and have verified that it is the instance included in Oracle that is being picked up, but the error still occurs. Any ideas?

(This is a follow-on from an earlier question regarding 10g and JAXB 2.)

+1  A: 

What version of Java are you using? The newest versions ship with this class in the rt.jar.

Revah
1.5.0_06 That would appear to include it. I don't know how to work around that, though. Removing it from both the webapp and oracle itself clearly isn't an option.
alexmcchessers
A: 

May be it's completely unrelated, but I remember a problem Weblogic had with the very same class. The reason for the problem was the changed serial id of the class (Sun changed it accidentally). The workaround was to provide a -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0 to the JVM.

Could it be the same problem, just misreported? Try it.

See here: http://forums.bea.com/thread.jspa?threadID=600014563

Vladimir Dyuzhev
+2  A: 

This class is in half the WS Java libraries out there. It's really easy to load it from multiple classloaders and later compare them, causing a LinkageError.

One effective (but sledgehammer) technique to tracking this down is to modify Classloader from the Java source to dump which jar this particular class is loading from at load time, then prepend your bootclasspath with your modified version:

-Xbootclasspath/p:/path/to/hackedBin

Alex Miller
A: 

Can you just update the JAXB jar under the app server's lib folder?

matt b