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:
I have patched 'javassist.Loader.loadClassByDelegation' to delegate the 5 additional prefixes that the jUnit documentation recommends:
private Class loadClassByDelegation(String name)
/* 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 (name.startsWith("java.") || name.startsWith("javax.")
|| name.startsWith("sun.") || name.startsWith("com.sun.")
c = delegateToParent(name);
This fixes the problem. Please feel free to use this patch.