[jdom-interest] Using Project X SAX Parser with JDOM

Kevin Swanson KDSwanson at tallysys.com
Thu Jun 29 12:47:13 PDT 2000


I'm trying to use Sun's Project X SAX parser in place of the default Xerces
parser. You are probably asking why. I've encountered a weird bug in my IDE
(VisualCafe 4.0), where using the Xerces parser blows up when i run it in
the debugger. So, I tried a bit of code like below where f is an
InputStream.

SAXBuilder builder = new SAXBuilder("com.sun.xml.parser.SAXParserImpl");
doc = builder.build(f);

When this runs, I get the following error:

org.jdom.JDOMException: SAX2 driver class com.sun.xml.parser.SAXParserImpl
loaded but cannot be instantiated (no empty public constructor?): SAX2
driver class com.sun.xml.parser.SAXParserImpl loaded but cannot be
instantiated (no empty public constructor?)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:231)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:250)
        at com.tallysys.jdom.JDOMTest.<init>(JDOMTest.java:26)
        at com.tallysys.jdom.JDOMTest.main(JDOMTest.java:82)
Root cause: java.lang.InstantiationException:
com/sun/xml/parser/SAXParserImpl
        at
org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory
.java:124)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:167)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:250)
        at com.tallysys.jdom.JDOMTest.<init>(JDOMTest.java:26)
        at com.tallysys.jdom.JDOMTest.main(JDOMTest.java:82)

Is this because JDOM expects a SAX2 parser and Sun's is only SAX1? Is there
a way around this problem?

Thanks,

Kevin




More information about the jdom-interest mailing list