• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using jdom to read xmlfile

 
Daksha Tulshikar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Roy2002
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.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 ]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic