You probably need to put Xerces into the Tomcat lib directory, or some
other directory that serves as an "endorsed" override to the JDK's
version (or some other JAXP that gets loaded before your webapp).
In different appservers, there are different conventions for whether the
container's classpath is used first, or the webapp's classpath. Some of
them support a switch you can set in the webapp telling which you want,
but it can be problematic to put the webapp's path first. Example, if
you override the container's log4j jar in the webapp, the webapp will be
using a different Logger class than the container, and strange things
will happen.
But different webapps could use different XML parsers without a problem.
If you are sure your "better" version of some jar won't break other
webapps running in the container, you can put your version of some jar
in a directory shared by all the webapps and used by the container.
Jeff
Benson Margulies wrote:
By the way, is this combination of parsers in a backtrace alarming?
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:410)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3165)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2630)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2037)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685)
at
com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:549)
at
org.apache.xerces.jaxp.JAXPValidatorComponent$XNI2SAX.startElement(Unknown
Source)
at
org.apache.xerces.jaxp.JAXPValidatorComponent.startElement(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
On Thu, Oct 29, 2009 at 1:41 PM, Michael Glavassevich
<mrgla...@ca.ibm.com <mailto:mrgla...@ca.ibm.com>> wrote:
Hi Benson,
DocumentBuilderFactory and the other JAXP factories use the
current thread's context ClassLoader by default for locating the
implementation. If for whatever reason the implementation you
wanted loaded isn't visible to this ClassLoader you'll get a
different implementation, most likely the default one in the JDK.
Couldn't tell you how this is occurring in your environment. I've
never used Tomcat or Maven.
Thanks.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com <mailto:mrgla...@ca.ibm.com>
E-mail: mrgla...@apache.org <mailto:mrgla...@apache.org>
Benson Margulies <bimargul...@gmail.com
<mailto:bimargul...@gmail.com>> wrote on 10/29/2009 12:35:42 PM:
> I have some code that uses DocumentBuilderFactory etc. (JAXP) to
> parse a document with W3C schema validation.
>
> My unit tests work fine with Xerces in the classpath.
>
> When the business is all packaged into a webapp and deployed in
> tomcat (via mvn tomcat:run), the validation fails with bogus error,
> and the backtrace shows that I'm using whatever nasty version of
> JAXP is sitting in the JVM. Short of calling
> DocumentBuilderFactoryImpl, can anyone tell me what I'm doing wrong?
> The xerces Jar is in the WAR file in the right place.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-users-h...@xerces.apache.org