Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help .... XERCES DOM Parser

2 views
Skip to first unread message

Sariman

unread,
Jan 7, 2003, 3:57:18 PM1/7/03
to
I am sustaining a running website that allows user to import an XML
file and inserts the contenet into a database. The system has been
running fine until suddenly we got this nice looking message without
any code changes.


2003-01-07 12:33:08 - Ctx( ): Exception in: R( +
/WEB-INF/jsp/ControllerServlet + null) - java.lang.NoSuchMethodError
at org.apache.xerces.parsers.DOMParser.startElement(DOMParser.java:1131)
at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1284)
at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:949)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
at org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XMLValidator.java:2823)
at org.apache.xerces.validators.common.XMLValidator.parseSchemas(XMLValidator.java:2747)
at org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndAttributes(XMLValidator.java:2628)
at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1218)
at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:949)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
at ebl.common.XMLImport.getParsedDocument(XMLImport.java:97)
at ebl.workOrder.WOXML.execute(WOXML.java:78)
at ebl.workOrder.SaveNewXMLWOCommand.execute(SaveNewXMLWOCommand.java:30)
at ebl.ControllerServlet.process(ControllerServlet.java:277)
at ebl.ControllerServlet.doPost(ControllerServlet.java:252)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)

*******************************
the source code fails at this location
DOMParser prs = new DOMParser();
prs.setFeature("http://xml.org/sax/features/validation",
true);
prs.setFeature("http://xml.org/sax/features/namespaces",
true);
prs.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
pSchema);
prs.setEntityResolver(new XMLSchemaResolver(mSc));

XMLErrorHandler xeh = new XMLErrorHandler();
prs.setErrorHandler(xeh);
here>>> prs.parse(mSrc);
Document xmlDoc = prs.getDocument();
return xmlDoc;
**********************************

Phil Hanna

unread,
Jan 10, 2003, 11:00:59 PM1/10/03
to

On 7 Jan 2003 12:57:18 -0800, Mohamad...@westechinfosys.com
(Sariman) wrote:

>I am sustaining a running website that allows user to import an XML
>file and inserts the contenet into a database. The system has been
>running fine until suddenly we got this nice looking message without
>any code changes.
>
>
>2003-01-07 12:33:08 - Ctx( ): Exception in: R( +
>/WEB-INF/jsp/ControllerServlet + null) - java.lang.NoSuchMethodError
> at org.apache.xerces.parsers.DOMParser.startElement(DOMParser.java:1131)
>

"NoSuchMethodError" almost always means you are running a class A that
calls methods in class B, and the version of class B that was in the
classpath when you compiled A is not the same as the version you have
now. A quick look at the Xerces source code for
org.apache.xerces.parsers.DOMParser shows that the line specified in
the stack trace doesn't even exist anymore in later versions of
Xerces.

Recompile ControllerServlet and see what happens. The problem should
go away if you compile it against the same Xerces jars that you have
in your web application's classpath.


>*******************************
>the source code fails at this location
> DOMParser prs = new DOMParser();


Oooo -- bad. Unless you really need Xerces-specific features, you
should probably use the JAXP to invoke the DOM parser:

import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;
...

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
File file = new File(whatever);
Document doc = builder.parse(file);

with no references to "org.apache.xerces.anything".

That way you won't have to change anything if you need to run with
some other parser. No more code involved that you are already
writing.
--
Phil Hanna
Author of JSP 2.0: The Complete Reference
http://www.amazon.com/exec/obidos/ASIN/0072224371

0 new messages