Search code examples
javaeclipsexmlbeans

Why do I have XML-Related Apache classes throwing exceptions?


It seems like whenever I try to use XML-related classes in my Dynamic Web Projects in Eclipse and I try to run a class with a main method just for testing, I'm getting errors like AbstractMethodError and NoSuchMethodError.

It seems like some kind of classpath issue since I had identical versions of these projects running fine on my machine before it was formatted.

An example that tries to use XMLBeans:

Exception in thread "main" java.lang.NoSuchMethodError: com.ecw.adapterservice.schema.p2p.impl.ReferralRequestTypeImpl.generatedSetterHelperImpl(Lorg/apache/xmlbeans/XmlObject;Ljavax/xml/namespace/QName;IS)Lorg/apache/xmlbeans/XmlObject;

An example that tries to use a simple DOM parser:

Exception in thread "main" java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.setTextContent(Ljava/lang/String;)V

One interesting thing I noticed is that when I try to launch my executable class from within my project, Eclipse pops up a window that searches my entire project for 'main types'. I don't think I've ever seen it do this before and I suspect it may be related to the problems I'm having.

Again, please note that identical copies of the source/libs for these projects used to be able to run the same individual classes without issue.

Does anyone have any insight into this issue? This is driving me nuts.


Solution

  • It looks like both errors were the result of jar conflicts. Duly noted.