[jdom-interest] Again: Problem with Beta 7 and WebLogic 6.1

Daniel Hoppe hoppe at sitewaerts.de
Sun Aug 19 06:01:44 PDT 2001


Hi Jason,

thanks for your answer.

> 
> If I were in your shoes, I'd add debug stmts to check what's going on
> internally, and print out the underlying exception so we know exactly
> what reflection call is failing.
> 
Did that. See below for results.

> One thing to note: The builder's not "caching" the class name, that
> variable is supporting an override the user has if they don't want to
> use JAXP. 
> Its not being null means the user expressed a distinct
> preference.

Agree when it comes to the first invocation of build(InputSource in). On the
second invocation things look slightly different. Assume I have something
like this:

SAXBuilder saxb = new SAXBuilder(); // *No* distinct preference -> Use JAXP
saxb.build(inputSource1);
saxb.build(inputSource2);

createParser() is called both times in build(InputSource in).

What createParser() does in principle is the following (reduced to the
relevant part):

    protected XMLReader createParser() throws Exception {
        XMLReader parser = null;
        if (saxDriverClass != null) {
            parser = XMLReaderFactory.createXMLReader(saxDriverClass);
        } else {
                parser = (XMLReader)getXMLReader.invoke(jaxpParser, null);
                saxDriverClass = parser.getClass().getName();
        }
        return parser;
    }

On the first invocation of createparser, saxDriverClass is null,
createParser follows the 'else' path to get the parser via JAXP. Then the
saxDriverClass is set to the classname of the parser that was returned
during this wild JAXP introspection stuff. On the second invocation,
saxDriverClass is not null anymore and the parser is instantiated by
XMLReaderFactory.createXMLReader(saxDriverClass).

This method  basically does 

return (XMLReader)Class.forName(className).newInstance();

which fails as the WebLogic class has no public empty constructor. The
stack-trace looks like this one:

org.jdom.JDOMException: Error in building: SAX2 driver class
weblogic.xml.jaxp.RegistryXMLReader loaded but cannot be instantiated (no
empty public constructor?)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:306)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:650)
        at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.thisDoesNotWork(JDOMvsWL61.java:
48)
        at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.main(JDOMvsWL61.java:67)
Root cause: java.lang.InstantiationException:
weblogic.xml.jaxp.RegistryXMLReader
        at
org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:1
24)
        at org.jdom.input.SAXBuilder.createParser(SAXBuilder.java:360)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:283)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:650)
        at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.thisDoesNotWork(JDOMvsWL61.java:
48)
        at
de.sitewaerts.futuna.reproducers.JDOMvsWL61.main(JDOMvsWL61.java:67)


> 
> My suspicion is it's a WebLogic JAXP implementation issue (bug,
> different interpretation of the spec, etc).  Most people probably use
> the Sun JAXP reference implementation where it's known to work.
> 

The WebLogic class has this constructor "protected
RegistryXMLReader(SAXParser p0, SAXFactoryProperties p1)", so this can never
work. So I see two options left. Either WebLogic is wrong, and an XMLReader
must have an empty public constructor or JDom should not cache - given that
I'm read the code right - the classname, but rather re-run the JAXP
initialization (introspection -> slow?). 

Maybe this is a dumb question now, but why is there a need to obtain a new
instance of a parser anway? Couldn't the same parser be reconfigured and
reused?

Cheerios,

Daniel

<<<<<<<<<<<<<<<<<<<<<<<<<<<
sitewaerts GmbH
Hebelstraße 15
D-76133 Karlsruhe

Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
http://www.sitewaerts.de
>>>>>>>>>>>>>>>>>>>>>>>>>>>





More information about the jdom-interest mailing list