Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java 1.6 Xerces Incompatibility

669339Jan 20 2011 — edited Jan 20 2011
Im working on upgrading an enterprise application stack on a standard JEE server (moving from java 5 to 6) and have run into what seems to be an incompatibility between the JAXP/JAXB/SAAJ reference implementation included in the rt.jar and apache Xerces. Ive seen suggestions here and there about how to resolve the issue, but was wondering if there was a discussion somewhere about the specifics of this issue. I have searched for quite sometime and have found nothing that talks about why this conflict occurs. I can see that the reference implementation in the rt.jar has a different namespace, so why is the classloader not able to differentiate between one class and the other?

For example, when I have a deployment with the xercexImpl.jar in its classpath, I see the following exception cause upon initialization of my web framework:

Caused By: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

Using the -verbose:class java property on the command line when I start my server I can verify that the only other source of that class is the xercesImpl.jar. I assume that the reference implementation has altered the class hierarchy so that this cast is no longer valid, but a quick look in the rt.jar shows that the XIncludeAwareParserConfiguration class there is in package com.sun.org.apache.xerces.internal.parsers so Im just not understanding how there could be a conflict. However, placing xerces into my jre endorsed directory makes this issue disappear. Also, telling my JEE container to change its classloading strategy to prefer the WAR libs also seems to have resolved the conflict in one deployment, though not for a second. Perhaps I mistaken about whats going on but it sure seems from empirical evidence and from accounts on various forums that the conflict is between the the implementation that ships with Java 1.6 and the apache impl. Please help me understand the detail behind this issue.

Finally, I realize that the simplest solution might be to remove the xerces lib from my WAR, but unfortunately I have a dependency on 3rd party library that uses the xerces native api.

Edited by: user2149969 on Jan 20, 2011 6:39 PM

Edited by: user2149969 on Jan 20, 2011 6:44 PM

Edited by: user2149969 on Jan 20, 2011 6:51 PM

Edited by: user2149969 on Jan 20, 2011 6:52 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2011
Added on Jan 20 2011
0 comments
1,050 views