我在我们的一个实时服务器上不断收到以下异常(其他运行相同代码的服务器似乎没问题):
java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/domwith the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: No XPathFctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:67)
我很确定类路径中有 Xalan 和 Saxon jar(使用 IBM Java 1.5)。
您有什么其他可能出错的想法吗?
编辑:
这是导致问题的代码:
XPathFactory factory = XPathFactory.newInstance();
它运行在大致基于 catalina 引擎的自定义网络服务器上。
最佳答案
您需要在类路径中添加适当的 .jar。就我而言,我使用了 Saxon-HE 库。
There exists a bug in Saxon9 you maybe run into like me.
该错误已在版本 9.5.1.5 中得到纠正。所以你可以下载 latest Saxon 9 HE .
关于java - 使用 XPathFactory 的类路径问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/798333/