[jdom-interest] SAXBuilder.createParser() cannot load Piccolo

Martin Schulz schulz at videotron.ca
Sun Mar 2 15:38:36 PST 2003


Hi,

[ I've sent this once before, but didn't receive it through the list.
My apologies if this is turns out to be a duplicate ]

I would like to suggest a minor change to SAXBuilder.createParser() as
follows.

A while ago I came across a problem with setting up the Piccolo SAX
parser as the SAX parser of choice, when JDOM produced an Exception in
the reflection code in createParser:
java.lang.IllegalAccessException: Class org.jdom.input.SAXBuilder can
not access a member of class
com.bluecast.xml.JAXPSAXParserFactory$JAXPSAXParser with modifiers
"public"

The problem turns out to be that the Piccolo SAXParser class is not
accessible (it's an internal class with non-public access), but it's
only accessible via the SAXParser interface.

It's a technicality, but I think ceateParser() is broken in this regard,
hence the minimal code change below. This is of course to make
SAXBuilder more generically usable, not just for Piccolo, and I would
appreciate to see it checked in. 

Thanks.

   Martin

Here's the context diff against the current CVS tree for review:

***************
*** 463,475 ****
                  setValidating.invoke(factory,
                                       new Object[]{new
Boolean(validate)});

!                 // jaxpParser = factory.newSAXParser();
                  Method newSAXParser =
                      factoryClass.getMethod("newSAXParser", null);
                  Object jaxpParser  = newSAXParser.invoke(factory,
null);

!                 // parser = jaxpParser.getXMLReader();
!                 Class parserClass = jaxpParser.getClass();
                  Method getXMLReader =
                      parserClass.getMethod("getXMLReader", null);
                  parser = (XMLReader)getXMLReader.invoke(jaxpParser,
null);
--- 463,475 ----
                  setValidating.invoke(factory,
                                       new Object[]{new
Boolean(validate)});

!                 // SAXParser jaxpParser = factory.newSAXParser();
                  Method newSAXParser =
                      factoryClass.getMethod("newSAXParser", null);
                  Object jaxpParser  = newSAXParser.invoke(factory,
null);

!                 // XMLReader parser = jaxpParser.getXMLReader();
!                 Class parserClass =
Class.forName("javax.xml.parsers.SAXParser");
                  Method getXMLReader =
                      parserClass.getMethod("getXMLReader", null);
                  parser = (XMLReader)getXMLReader.invoke(jaxpParser,
null);




More information about the jdom-interest mailing list