Java dom4j org/jaxen/NamespaceContext 异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12933622/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java dom4j org/jaxen/NamespaceContext exception
提问by Mr.
I have downloaded dom4j-1.6.1and added it to java's build path. I am also familiar with java.lang.NoClassDefFoundError: org/saxpath/SAXPathExceptionbut I keep getting an exception.
我已经下载了dom4j-1.6.1并将其添加到 java 的构建路径中。我也熟悉java.lang.NoClassDefFoundError: org/saxpath/SAXPathException但我不断收到异常。
Enclosed a snippet:
附上一个片段:
public class Parser {
public static void parse(final String path) throws Exception {
final SAXReader reader = new SAXReader();
final Document document = reader.read(new File(path).toURI().toURL());
if (document == null) return;
List list = document.selectNodes("/");
for (Object o : list)
System.out.println(o);
}
}
When I run it, I get the following stack trace
当我运行它时,我得到以下堆栈跟踪
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/NamespaceContext
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 Parser.parse(Parser.java:15)
at Main.main(Main.java:6)
Caused by: java.lang.ClassNotFoundException: org.jaxen.NamespaceContext
at java.net.URLClassLoader.run(URLClassLoader.java:366)
at java.net.URLClassLoader.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 5 more
Any clue what causes the error?
任何导致错误的线索?
回答by vikiiii
The Exception:
例外:
java.lang.ClassNotFoundException: org.jaxen.NamespaceContext
Maybe you forgot to include the jaxen.jar
in your Java build's path.
也许您忘记jaxen.jar
在 Java 构建的路径中包含 。
For more specific instructions on using SAXReader to parse some XML and loop through the nodes: https://stackoverflow.com/a/24959790/445131
有关使用 SAXReader 解析一些 XML 并遍历节点的更具体说明:https: //stackoverflow.com/a/24959790/445131