xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertdon...@mac.com>
Subject Re: JAXP (in)compatability between Xerces and Crimson
Date Fri, 09 Nov 2001 18:19:35 GMT
"Andy Carlson" <andyslistbox@hotmail.com> wrote:

> Hi all,
> I've just spent quite a while tracking down a weird problem...
> I'm running a servlet under Tomcat 4.0. The servlet includes Axis, which 
> in this case is using the Xerces (1.4.3) parser. Everything works fine - 
> no problem so far...
> Now I try to run the same servlet on Tomcat 4.0 embedded in JBoss (2.4.1)
>  and I get the following:-
> java.lang.ClassCastException: 
> org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
> at 
> javax.xml.parsers.DocumentBuilderFactory.newInstance
> (DocumentBuilderFactory.java:152)

this is quite a well known problem. it boils down to classloaders.

standalone tomcat 4.0 works because it has classloaders specially 
rewritten to work with JAXP.
jboss uses a different system of classloaders and requires special 
configuration to make JAXP work.
the bad news is that some ejb containers are even worse than jboss...


> So what's the answer?
> - at the moment the answer seems to be to avoid mixing Crimson and Xerces 
> in the same context unless you have a very good understanding of how they 
> are going to interact with each other - you might get away with it or you 
> might (like me) spend a long time chasing strange problems.
> ... but this is bad news because it means that if my servlet uses an XML 
> parser, I have to check whether the app server I'm deploying on is using 
> another one in a way which is going to cause a conflict.
> - For the future it would seem to be a better approach to agree on a 
> single implementation of JAXP within Apache, put it in its own JAR and 
> explicitly disallow (in the JAXP spec?) XML parser implementations from 
> reimplementing all or part of JAXP in their own JARs.

this isn't an apache problem - it's a JAXP problem.
even with only one apache implementation you'd still get version conflicts 

if you want deployment independence i'd say you've got two choices:

1. throw away JAXP and directly use the parser of your choice. parser 
independence is vital for components but isn't really necessary if you're 
writing a web application.

2. don't deploy any parser libraries with your application and insist that 
JAXP is correctly set up on the deployment system before you deploy.

- robert

In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

View raw message