Menu

#34 XMLReaderFactory and classloader

SAX_2.0
closed-duplicate
nobody
5
2002-01-29
2002-01-28
Anonymous
No

I have run into a problem with your implementation of
XMLReaderFactory in the J2EE environment.

The problem is that your implementation uses
Class.forName. As I assume you certainly know, this is
not "up-to-date" (see
http://www.javageeks.com/Papers/ClassForName/ for details).

I therefore propose the attached patch.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    (There seems to ba a bug when trying to submit an error
    with an attachment - I got an error. Here is the patch.
    - mnl@mnl.de)

    *** XMLReaderFactory.java.orig Thu Nov 15 20:26:47 2001
    --- XMLReaderFactory.java Sat Jan 12 14:47:54 2002
    ***************
    *** 113,119 ****
    throws SAXException
    {
    try {
    ! return
    (XMLReader)(Class.forName(className).newInstance());
    } catch (ClassNotFoundException e1) {
    throw new SAXException("SAX2 driver class " +
    className +
    " not found", e1);
    --- 113,120 ----
    throws SAXException
    {
    try {
    ! ClassLoader cl =
    Thread.currentThread().getContextClassLoader();
    ! return
    (XMLReader)cl.loadClass(className).newInstance();
    } catch (ClassNotFoundException e1) {
    throw new SAXException("SAX2 driver class " +
    className +
    " not found", e1);

     
  • Nobody/Anonymous

    Logged In: NO

    Patch got lost when I submitted the error:

    *** XMLReaderFactory.java.orig Thu Nov 15 20:26:47 2001
    --- XMLReaderFactory.java Sat Jan 12 14:47:54 2002
    ***************
    *** 113,119 ****
    throws SAXException
    {
    try {
    ! return
    (XMLReader)(Class.forName(className).newInstance());
    } catch (ClassNotFoundException e1) {
    throw new SAXException("SAX2 driver class " +
    className +
    " not found", e1);
    --- 113,120 ----
    throws SAXException
    {
    try {
    ! ClassLoader cl =
    Thread.currentThread().getContextClassLoader();
    ! return
    (XMLReader)cl.loadClass(className).newInstance();
    } catch (ClassNotFoundException e1) {
    throw new SAXException("SAX2 driver class " +
    className +
    " not found", e1);

     
  • Anonymous

    Anonymous - 2002-01-29

    Logged In: YES
    user_id=44117

    This has been fixed in the sax2 r2pre2 and r2pre3
    releases for many months now. And in a way that
    doesn't impose an undesirable jdk 1.2 requirement.
    UPGRADE!

     
  • Anonymous

    Anonymous - 2002-01-29
    • status: open --> closed-duplicate
     

Log in to post a comment.