[jdom-interest] Help with JDOM and JSP
Brett McLaughlin
brett.mclaughlin at lutris.com
Thu Aug 10 08:37:02 PDT 2000
You have the DOM Level 1 classes in your classpath before the DOM Level
2 classes. You problably have something like xml.jar in your servlet
engine classpath before xerces.jar - simply change this order and it
will work fine.
-Brett
Robert Schiffer wrote:
>
> Hello all,
> I am trying to parse and print the contents of an XML file using JSP;
> however, I get the following exception:
>
> Thu Aug 10 10:40:55 EDT 2000:<E> <HTTP> java.lang.NoSuchMethodError:
> org.w3c.dom.DocumentType: method getPublicId()Ljava/lang/String; not found
> at org.jdom.input.DOMBuilder.buildTree(Compiled Code)
> at org.jdom.input.DOMBuilder.buildTree(Compiled Code)
> at org.jdom.input.DOMBuilder.build(DOMBuilder.java:230)
> at servlets.jsp._xml._loadxml._jspService(Compiled Code)
> at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Compiled
> Code)
> at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled Code)
> at weblogic.servlet.JSPServlet.service(Compiled Code)
> at javax.servlet.http.HttpServlet.service(Compiled Code)
> at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Compiled
> Code)
> at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled Code)
> at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(Compiled Code)
> at weblogic.socket.MuxableSocketHTTP.invokeServlet(Compiled Code)
> at weblogic.socket.MuxableSocketHTTP.execute(Compiled Code)
> at weblogic.t3.srvr.ExecuteThread.run(Compiled Code)
>
> java.lang.NoSuchMethodError is a run-time Error. The JSP code compiles, so
> the appropriate packages (in this case jdom-b4.jar) are in my classpath.
> Can anyone provide some insight into this error?
>
> The following is the JSP page that receives the XML file. The error occurs
> on the following line:
>
> org.jdom.Document jdomDoc = (new DOMBuilder(false)).build(doc);
>
> Here is the jsp page:
>
> <html>
> <body>
> <table>
> <tr>
> <td><font face="arial,helvetica">
> <%@ page language="java" %>
> <%@ page import="org.w3c.dom.*" %>
> <%@ page import="org.xml.sax.*" %>
> <%@ page import="javax.xml.parsers.*" %>
> <%@ page import="org.jdom.input.*" %>
> <%
> try {
> com.oreilly.servlet.MultipartRequest multi = new
> com.oreilly.servlet.MultipartReque
> st(request, ".");
>
> Enumeration files = multi.getFileNames();
> while (files.hasMoreElements()) {
> String name = (String)files.nextElement();
> File f = multi.getFile(name);
> if (f != null) {
> DocumentBuilderFactory dbf = null;
> DocumentBuilder db = null;
> Document doc = null;
> try {
> dbf = DocumentBuilderFactory.newInstance();
> db = dbf.newDocumentBuilder();
> }
> catch(ParserConfigurationException pce) {
> pce.printStackTrace();
> }
> try {
> doc = db.parse(f);
> }
> catch(IOException ioe) {
> ioe.printStackTrace();
> }
> catch(SAXException saxe) {
> saxe.printStackTrace();
> }
> org.jdom.Document jdomDoc = (new DOMBuilder(false)).build(doc);
> try {
> org.jdom.Element element = jdomDoc.getRootElement();
> List children = element.getChildren();
> for (int i=0; i<children.size(); i++) {
> org.jdom.Element child = (org.jdom.Element)children.get(i);
> System.out.println("MessageReader:XML document contains node
> " + child.ge
> tName() + " value is " + child.getContent()); }
> }
> catch (org.jdom.NoSuchElementException nsee) {
> nsee.printStackTrace();
> }
> }
> }
> }
> catch(NullPointerException npe) {
> System.out.println(npe.toString());
> }
> catch(java.io.IOException ioe) {
> System.out.println(ioe.toString());
> } %>
> </td>
> </tr>
> </table>
> </form>
> </body>
> </html>
>
> Thank you for your help.
>
> Rob
>
> ____________________________________________
> Robert Schiffer
> F o r t P o i n t P a r t n e r s I n c .
> rschiffer at fortpoint.com
> www.fortpoint.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
--
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc.
1200 Pacific Avenue, Suite 300
Santa Cruz, CA 95060 USA
http://www.lutris.com
http://www.enhydra.org
More information about the jdom-interest
mailing list