[jdom-interest] Errors trying to create Document from SAXBuilder with jdom b6

Aaron M. Oathout aoathout at McLeodUSA.com
Thu Mar 15 09:50:12 PST 2001



Hopefully someone can help me with this. I'm fairly new to Java, and this is my
first crack at using jdom.

I've been going through this "java and xml" book from oreilly and when i try to
run the example program they have
I keep getting the following error when it tries to create a document using the
SAXBuilder class. Can anyone shed any light
on what could possibly be wrong here?

Here's the error I'm getting:

Exception in thread "main" java.lang.NoSuchMethodError
        at org.jdom.input.SAXHandler.startElement(SAXBuilder.java:727)
        at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1289)
        at
org.apache.xerces.framework.XMLParser.callStartElement(XMLParser.java:1922)
        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 JDOMTest.saxDocument(JDOMTest.java:81)
        at JDOMTest.main(JDOMTest.java:118)


Here's the code that calls my function:

          test.saxDocument( new File( args[0] ), System.out );

Here's the function definition:

    public void saxDocument( File file, OutputStream out ) throws IOException,
JDOMException {
        SAXBuilder builder = new SAXBuilder( false );
        Document doc    = builder.build( file );

        XMLOutputter fmt = new XMLOutputter();
        fmt.output( doc, out );
    }

Here are my import statements:
     import java.io.File;
     import java.io.IOException;
     import java.io.OutputStream;

     /* JDOM Interfaces */
     import org.jdom.Attribute;
     import org.jdom.Comment;
     import org.jdom.DocType;
     import org.jdom.Document;
     import org.jdom.Element;
     import org.jdom.JDOMException;
     import org.jdom.Namespace;
     import org.jdom.Namespace;
     import org.jdom.ProcessingInstruction;
     import org.jdom.input.DOMBuilder;
     import org.jdom.input.SAXBuilder;
     import org.jdom.output.XMLOutputter;


The program does 2 different things:
     1.   Creates a document from scratch with no xml input
     2.   Creates a document from an xml file using the DOMBuilder class
     3.   Creates a document from an xml file using the SAXBuilder class

The code works great for the first 2 things, but chokes on the SAX methods. Any
ideas? Anyone?


Thanks,

Aaron





More information about the jdom-interest mailing list