0 Replies Latest reply on May 28, 2003 2:11 PM by Jeff Grigg

    problems processing XML -- found and fixed

    Jeff Grigg Newbie

      Encountering 'java.lang.IncompatibleClassChangeError' exception when attempting to call methods of an instance of class 'com.sun.xml.tree.ElementNode' (Sun's implementation of the 'org.w3c.dom.Element' interface) from within a javassist loaded class.

      The problem is that javassist delegates loading of 'com.sun.xml.tree.ElementNode' to the native loader, but javassist loads 'org.w3c.dom.Element' itself.

      The fix is to patch javassist to delegate loading of 'org.w3c.dom.*' classes to the native loader.

      This is a problem the jUnit developers encountered. They describe their fix here:

      http://junit.sourceforge.net/doc/faq/faq.htm#running_9

      I have patched 'javassist.Loader.loadClassByDelegation' to delegate the 5 additional prefixes that the jUnit documentation recommends:

      private Class loadClassByDelegation(String name)
      throws ClassNotFoundException
      {
      /* The swing components must be loaded by a system
      * class loader.
      * javax.swing.UIManager loads a (concrete) subclass
      * of LookAndFeel by a system class loader and cast
      * an instance of the class to LookAndFeel for
      * (maybe) a security reason. To avoid failure of
      * type conversion, LookAndFeel must not be loaded
      * by this class loader.
      */

      Class c = null;
      if (doDelegation)
      if (name.startsWith("java.") || name.startsWith("javax.")
      || name.startsWith("sun.") || name.startsWith("com.sun.")
      //%%%PATCH%%%//
      || name.startsWith("org.omg.")
      || name.startsWith("sunw.")
      || name.startsWith("org.w3c.dom.")
      || name.startsWith("org.xml.sax.")
      || name.startsWith("net.jini.")
      //%%%PATCH%%%//
      || notDelegated(name))
      c = delegateToParent(name);

      return c;
      }


      This fixes the problem. Please feel free to use this patch.