Details
Description
Following exception occurs intermittently:
Uncaught exception
java.lang.IncompatibleClassChangeError: Class org.jaxen.JaxenHandler does not
implement the requested interface org.jaxen.saxpath.XPathHandler
at org.jaxen.saxpath.base.XPathReader.parse(XPathReader.java:98)
The line is:
getXPathHandler().startXPath();
in XPathReader.parse.
We have debugged a similar error in other code previously. The error is caused by the throws clauses not matching between the implementation and the interface (JaxenHandler implementing XPathHandler). In the particular call the startXPath method is defined by the interface to throw a SAXPathException and the implementation throws no exception. It appears all of the methods in JaxenHandler are inconsistent either throwing nothing or throwing a JaxenException.
Even though this is an intermittant issue it should be corrected. Once it appears there seems to be a tendency for the user to see it many times over. The user has to restart their application before they can resume what they are working on.
That exception isn't caused by what you describe. If it was, you'd see it all the time - its very common to have code like this. For example, look at ByteArrayInputStream's read methods versus the ones in InputStream. You might /appear/ to resolve the situation by adding the throws clause and recompiling, but more likely it was just the act of a fresh compile that fixed the bug.
The exception is caused by loading incompatible versions of a class; in other words, a different version of jaxen, or one compiled with a different version of javac. You don't describe the specific environment in which you saw this problem, but I'm 99% certain you're looking at an appserver which has more than one copy of jaxen (or saxpath) sitting around, and some lack of isolation in your classloaders is causing your grief.
A common cause of this exception (for all kinds of code) used to be the work directory in tomcat needing cleaned out.