gpt4 book ai didi

Java dom4j org/jaxen/NamespaceContext 异常

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:06:46 32 4
gpt4 key购买 nike

我已经下载dom4j-1.6.1并将其添加到 java 的构建路径中。我也很熟悉 java.lang.NoClassDefFoundError: org/saxpath/SAXPathException但我不断收到异常。

附上一个片段:

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);
}
}

当我运行它时,我得到以下堆栈跟踪

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$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.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

任何导致错误的线索?

最佳答案

异常:

java.lang.ClassNotFoundException: org.jaxen.NamespaceContext

也许您忘记在 Java 构建路径中包含 jaxen.jar

有关使用 SAXReader 解析某些 XML 并循环遍历节点的更多具体说明: https://stackoverflow.com/a/24959790/445131

关于Java dom4j org/jaxen/NamespaceContext 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12933622/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com