Hi, I hope this email reaches the mailing list. I subscribed 10+ minutes ago, but haven't received a response from your mailing list manager. As a result, I'd appreciate it if any replies can be Cc:'ed to my email address. Thanks.
Here's my situation, and I'm hoping somebody can comment on it. In ant, when I run my junits, I assemble a classpath that contains weblogic.jar. We use WebLogic 6.1 SP2 (which is not compatible with JDK 1.4 and the newer XML libraries). I have a junit test that uses Apache SOAP (v2.2) to make a call to our application. When SOAP tries to assemble the XML message to post to the servlet on the server side, it needs to load a parser. How does it do so? It uses javax.xml.parsers.DocumentFactory. This class is defined both in rt.jar (which comes with JDK 1.4) as well as in weblogic.jar. I'll refer to DocumentFactory(w) as the WebLogic version of DocumentFactory, and DocumentFactory(j) as the JDK version of DocumentFactory. When ant's classloader is asked to load javax.xml.parsers.DocumentFactory, it uses the parent classloader (the JDK classloader) because the constructor for AntClassLoader calls addSystemPackageRoot("javax"). When the loadClass(...) method in AntClassLoader is called, if the class to be loaded begins with any of the "system packages" (java or javax), it delegates loading to the parent classloader (the system classloader). The result? AntClassLoader returns DocumentFactory(j) (the DocumentFactory that comes with JDK 1.4). Sounds reasonable to me... DocumentFactory (or some class that DocumentFactory calls) uses an org.xml.sax.InputSource. This class is also defined both in rt.jar from the JDK distribution as well as in weblogic.jar. When DocumentFactory tries to load InputSource, AntClassLoader looks at "org.xml.sax.InputSource" and says "that's not a system package", and thus it (AntClassLoader) loads the class using it's own rule(s) (which really just use the classpath I have defined in my build.xml). The result? AntClassLoader returns InputSource(w) (the InputSource that comes with weblogic) because it starts with org.xml.sax and is not a system package. When all the dust settles, I have a DocumentFactory from the JDK and an InputSource from weblogic. The two don't line up, and I get a LinkageError. I changed the source code for the constructor for AntClassLoader so that it does *not* add javax as a system package. This forced AntClassLoader to load the DocumentFactory from weblogic.jar instead of rt.jar, and since InputSource is read from weblogic.jar everything lined up and the my unit test ran successfully. I'm writing because I'm not particularly happy with changing the source code of an open source project without notifying the maintainers of my problem and asking for any advice or insight they may have into a solution. I realize that part of this problem derives from using weblogic.jar, but I'm unwilling to accept that as the full explanation (saying Ant 1.5.1 and WebLogic 6.1 SP2 are *incompatible* seems a bit harsh). Any words of wisdom? -c -- 10:50am up 114 days, 2:25, 1 user, load average: 0.68, 0.62, 1.33