File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes using jdom to read xmlfile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "using jdom to read xmlfile" Watch "using jdom to read xmlfile" New topic
Author

using jdom to read xmlfile

Daksha Tulshikar
Greenhorn

Joined: Jun 21, 2001
Posts: 2
I have used Jdom to read an xml file by creating SaxBuilder instance and building the document using the buid command.
On the console it is working fine.
But as a servlet it is giving me errors.
It gives the following error
Error: 500
Internal Servlet Error:
java.lang.NoSuchMethodError: org.xml.sax.Attributes: method getQName(I)Ljava/lang/String; not found
at org.jdom.input.SAXHandler.startElement(SAXBuilder.java:727)
at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1256)
at org.apache.xerces.framework.XMLParser.callStartElement(XMLParser.java:1920)
at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1831)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1223)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1208)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:395)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:464)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:445)
at Item.doPost(Item.java:58)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:772)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:641)
at org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:549)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:392)
at org.apache.tomcat.core.InvokerServlet.service(InvokerServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:641)
at org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:549)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:392)
at org.apache.tomcat.core.Context.handleRequest(Context.java:732)
at org.enhydra.servlet.servletManager.ServletManager.service(ServletManager.java:1092)
at org.enhydra.servlet.connectionMethods.http.HttpHandler.doARequest(HttpHandler.java:238)
at org.enhydra.servlet.connectionMethods.http.HttpHandler.processRequests(HttpHandler.java:255)
at org.enhydra.servlet.connectionMethods.http.HttpHandler.run(HttpHandler.java:93)
at java.lang.Thread.run(Thread.java:498)
Can anyone tell the solution to solve this problem.


[This message has been edited by Daksha Tulshikar (edited June 21, 2001).]
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

is your CLASSPATH (order in which the jars appear) same on the
command line and in the app server when it is running.
it is possible that the first class it finds may not have the
required method and so the Exception.
i would personally check this first.
regds.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Roy2002
Greenhorn

Joined: Nov 09, 2001
Posts: 6
Daksha Tulshikar,
Hi,
I have faced the same problems with the saxon xsl stylesheet processor, could U give me some tips that how did U solve it?
Thanks.
Roy
Huangrh@web.de
shaonan zhang
Greenhorn

Joined: Dec 12, 2002
Posts: 9
.I also have the same question.I want somebody who has experience of xml'programme on servlet has a good talk for us.
Think for all!
[ January 16, 2003: Message edited by: shaonan zhang ]

study hard, day day up!
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi all,
JDOM requires a parser that supports DOM Level 2 and SAX 2.0.
Your error is due to a version of parser that does not support SAX 2.0.
You will have to do the following:
1. download a more recent version of your parser that support SAX 2.0 and DOM Level 2.
2. Add this parser to the classpath of your web server (and possibly remove the old parser archive)
(1) For instance, Xerces Java Parser 1.4.4 would fits your needs. Also JDOM comes bundled with a version of Xerces that has been fully tested to work with all JDOM APIs.
The following document found on the JDOM web site gives more details:
JDOM Frequently Asked Questions
Cheers
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Well, if you are using tomcat3, then you also need get rid of some jar files came with tomcat. However, I'll strongly suggest you upgrade to tomcat4.1.18. That would solve many of your problems, since tomcat4 seperates the tomcat classpath with your application classpath. They don't interfere each other any more.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using jdom to read xmlfile