I get the following exception when trying to access any nodes of a parsed xml document on dom4j:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230) at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207) at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164) at xmlparser.LevelsExtractor.findI(LevelsExtractor.java:73) at xmlparser.Main.main(Main.java:33)
I know that the parsing works, because I can have the parser print out the xml document or save it to file. Here is the code I'm using.
To parse the document:
public class Parser { public Document parseWithSAX(File aFile) throws DocumentException { SAXReader xmlReader = new SAXReader(); Document doc = xmlReader.read(aFile); return doc; }
To try to get a node I've tried the following lines, all of which produce the same error:
List list = doc.selectNodes(""); QName qn = new QName("////Token/text()='Introduction'"); Element el = doc.selectSingleNode("////Token/text()='Introduction'"); Node node = doc.selectSingleNode( "/DOCUMENT/PAGE/TEXT/TOKEN/text()= 'Introduction'");
This will print out the xml doc which I assume means that doc (which is the parsed xml doc) contains what it should.
System.out.println(doc.asXML());
I really appreciate your help!
If you're using mvn2, the following will work with dom4j 1.6.1:
<dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> <version>1.1.1</version> </dependency>
That being said, I hope they fix their pom and save everyone this trouble.
You should add jaxen library to your class path.
EDIT: Actually original dom4j distribution contains jaxen.jar in that as well as all other dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With