geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toby cabot <t...@caboteria.org>
Subject problem with xerces and web apps
Date Mon, 24 Jan 2005 21:56:35 GMT
Hi Folks,

I've been using Geronimo for a while now and it works great.  I just
updated from Subversion today and now I have a problem at run-time
with Xerces inside a web app that appears to be classloader related.
I'm using Axis which uses Xerces so I added the xerces jars to my .war
file.  When Xerces starts I get:

java.lang.ClassCastException
        at org.apache.xerces.parsers.DOMParser.<init>(DOMParser.java:138)
        at org.apache.xerces.parsers.DOMParser.<init>(DOMParser.java:108)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:52)
        at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:47)
        at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:291)
        at org.apache.axis.utils.XMLUtils.newDocument(XMLUtils.java:308)
        at org.apache.axis.configuration.FileProvider.configureEngine(FileProvider.java:176)
        at org.apache.axis.AxisEngine.init(AxisEngine.java:162)
        at org.apache.axis.AxisEngine.<init>(AxisEngine.java:146)
        at org.apache.axis.server.AxisServer.<init>(AxisServer.java:87)
        at org.apache.axis.server.DefaultAxisServerFactory.createServer(DefaultAxisServerFactory.java:109)
        at org.apache.axis.server.DefaultAxisServerFactory.getServer(DefaultAxisServerFactory.java:73)
        at org.apache.axis.server.AxisServer.getServer(AxisServer.java:72)
        at org.apache.axis.transport.http.AxisServletBase.getEngine(AxisServletBase.java:183)
        at org.apache.axis.transport.http.AxisServletBase.getOption(AxisServletBase.java:370)
        at org.apache.axis.transport.http.AxisServletBase.init(AxisServletBase.java:110)
        at javax.servlet.GenericServlet.init(GenericServlet.java:168)

The Xerces code looks like (see [1]):

        super((XMLParserConfiguration)ObjectFactory.createObject(
            "org.apache.xerces.xni.parser.XMLParserConfiguration",
            "org.apache.xerces.parsers.XML11Configuration"
            ));

So it looks as if the problem is that the object that comes back from
ObjectFactory.createObject() can't be cast to an
XMLParserConfiguration.  The strange part is that it looks as if the
correct object is coming back, at least if I just print out the class
name.  The difference between a 2 week old Geronimo build and this one
is that this one appears to have two different instances of
org.apache.geronimo.jetty.JettyClassLoader in play, whereas the 2 week
old version only had one.  Xerces ObjectFactory has explicit code to
find the right classloader to use, their code is in findClassLoader()
at [2], in the two week old Geronimo build that code returned the same
classloader that this.getClass().getClassLoader() returns and the cast
succeeds, in the current build it finds a different classloader and
the cast throws a ClassCastException.

Any ideas how I can get around this are appreciated.

Thanks,
Toby

[1] DOMParser.java: http://cvs.apache.org/viewcvs.cgi/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java?rev=1.72&view=auto
[2] Code that Xerces uses to find the classloader: 
http://cvs.apache.org/viewcvs.cgi/xml-xerces/java/src/org/apache/xerces/parsers/ObjectFactory.java?rev=1.9&view=auto

Mime
View raw message