运行错误信息如下:
[org.dom4j.tree.DefaultElement@7a84e4 [Element: <root attributes: [org.dom4j.tree.DefaultAttribute@1aaa14a [Attribute: name name value "max"]]/>]]
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 test2.Test.main(Test.java:21)
Exception in thread "main"
错误出在List list = document.selectNodes("//root/author");这里,但我不知道为什么错
------解决方法--------------------------------------------------------
少包 jaxen.jar
------解决方法--------------------------------------------------------
同上,在dom4j的解压包lib目录下把jaxen.jar放到你的类路径里去
总结java.lang.NoClassDefFoundError可能有俩种:
1.java.lang.NoClassDefFoundError指向的"org/jaxen/JaxenException "这个字符串所指对象的类不存在
如不是自定义类的话,到 http://www.findjar.com 查找包含该信息的jar包并引入.
2.类的加载先后顺序有问题
如启动web application的时候,类的加载是有一个先后顺序的,如果应该先加载的类在后面加载,别的类在调用时找不到它,那么也会报这个错.
其他 java.lang.NoClassDefFoundError 异常处理都可这样处理.