Hello people. I have a method, which given an a dom4j Document instance and an xpath (String), returns the result of the xpath applied to the Document...
public static String[] getXpathExpressionResult(Document doc, String xPathExpression) {
String[] results = null;
Document testDoc = null; // this Document reference is fine
List resultObjects = doc.selectNodes(xPathExpression); // this returns a list of Node or String instances
if ( (!resultObjects.isEmpty()) && (resultObjects.size() != 0) ) {
results = StringUtils.toStringArray(resultObjects);
}
return results;
}
...I have dom4j and jaxen on my classpath and everything compiles well. The problem I get is when I try to run this method and I get a NoClassDefFoundError for the dom4j Document. It looks like a classpath issue but is not.
The error occurs here...
List resultObjects = doc.selectNodes(xPathExpression);
...yet the line before that one is fine (it too has a reference to a Document.
What's going on?