• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Help! Exception at jdom.input.DOMBuilder.build()

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get the following error when i try to run a class from a JSP hosted on the tomcat server. The code is in a class called updateXML.class. The same code works when i call the update method of that class from main function of another java class.
The code:
public class updateXML
public void updateXML() {}
public void update(String bgcolorlight, String bgcolordark)
try {
InputStream is = new FileInputStream("c:\\xyz\\src\\key.xml");
DOMBuilder dombuild = new DOMBuilder();
Document d = dombuild.build(is);
Element root = d.getRootElement();
The error:
org.jdom.JDOMException: Error in building from stream: null
at org.jdom.input.DOMBuilder.build(DOMBuilder.java:298)
at updateXML.update(updateXML.java:19)
at src._0002fsrc_0002fwizardServ_0002ejspwizardServ_jsp_1._jspService(_0
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
at java.lang.Thread.run(Thread.java:484)
Root cause: java.lang.NoSuchMethodError
at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:517)
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is about the the FileInputStream 'is'. For some reason it is invalid. Try prefixing the path c:\\xyz\\src\\key.xml with "file:\\" qualifier and see if that works.
Pranav Vashishtha
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ajit,
thanx, but the error was not because of the FileInputStream.
I figured out the error. took me a day. It was because tomcat server uses an older version of the DOM api than used by JDOM. So during startup when tomcat places the jar files(it needs to parse its own server.xml and web.xml files) dynamically in the classpath at the begining. So the JSP was instantiating an older version of the org.w3c.xml.DocumentType interface which does not have some of the methods used by the new JDOM api's DOMBuilder class. Hence it was giving the NoSuchMethodError. I had to chage the tomcat.bat file to make my JSP run. I just made sure that the parser.jar was appended at the end of classpath and not beginning.
thanx a lot.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!