views:

60

answers:

3

I've a chunk of code that works fine in isolation, but used a dependency in a clients project fails. A call to

Document doc = impl.createDocument(null,null,null);

fails (looks like the problem at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4913257). The instance of 'impl' in my unit tests is an instance of com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl. In my clients code, its an instance of org.apache.xerces.dom.DOMImplementationImpl.

How do I trace back this dependency? I've tried manually going through all classes and jar files in the classpath, but cannot find the provider of org.apache.xerces.dom.DOMImplementation. Is is possible to observe when classes are loaded (and why)? How is the particular DOM implementation selected? Can I for now force the jvm to use a particular implementation?

A: 

Most likely you do not have xercesImpl.jar in the client project's classpath

David Rabinowitz
+1  A: 

The implementation in the "com.sun.org.apache..." package is the Xerces that's packaged as part of the JRE. The one starting "org.apache..." is the standalone distribution from Apache. They can be run together in the same application, but it can get quite confusing.

Your client's project would appear to contain a copy of the standalone apache distribution (probably xercesImpl.jar). Ask them to rem,ove it and see if it starts using the built-in JRE code.

skaffman
That makes sense. Now the question comes to which jar has the apache distribution. There's no xercesImpl in the classpath, and I can't find which jar has the org.apache.xerces.* classes. Running with -Djaxp.debug=true printsJAXP: found jar resource=META-INF/services/javax.xml.parsers.DocumentBuilderFactory using ClassLoader: sun.misc.Launcher$AppClassLoader@53372a1abut it sadly doesn't say which jar.
eaubin
There must be a JAR in there containing a META-INF/services/javax.xml.parsers.DocumentBuilderFactory entry. Remember to also check inside the client's JRE installation too, they might have dropped xerces in there.
skaffman
A: 

Hi,

I think you could deal with endorsed standards stuff.

ATorras