Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NoClassDefFoundError org/dom4j/Document

843834Feb 1 2007 — edited Feb 7 2007
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 7 2007
Added on Feb 1 2007
8 comments
415 views