找不到XPathFactoryImpl错误(使用myBatis) [英] XPathFactoryImpl not found error (using myBatis)
问题描述
使用myBatis standAlone(Atlassian jira插件(OSGi)环境)
Using myBatis standAlone (Atlassian jira plugin(OSGi) environmnent)
发生以下错误.
[INFO] [talledLocalContainer] org.apache.ibatis.exceptions.PersistenceException:
[INFO] [talledLocalContainer] ### Error building SqlSession.
[INFO] [talledLocalContainer] ### Cause: java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default o
bject model: http://java.sun.com/jaxp/xpath/dom with the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: java.
util.ServiceConfigurationError: javax.xml.xpath.XPathFactory: Provider org.apache.xpath.jaxp.XPathFactoryImpl not found
[INFO] [talledLocalContainer] ### Cause: java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/dom with the XPathFactoryConfigurationException:javax.xml.xpath.XPathFactoryConfigurationException: java.util.ServiceConfigurationError: javax.xml.xpath.XPathFactory: Provider org.apache.xpath.jaxp.XPathFactoryImpl not found
源代码
static {
try {
// set SessionFactory
if (MyBatisConnectionFactory.sqlSessionFactory == null) {
MyBatisConnectionFactory.sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("/mybatisConfig.xml"));
}
} catch (final Exception e) {
MyBatisConnectionFactory.LOGGER.error(e.getMessage());
} finally {
}
}
添加xalan时,发生以下错误.
When adding xalan, the following error occurs.
Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
在纯Java应用程序环境中未发生此错误.
This error did not occur in Pure Java Application environment.
我想知道为什么会发生此错误.
I wonder why this error occurs.
请帮助我.
谢谢.
推荐答案
我遇到了类似的错误,这看起来很尴尬,此处记录,为我修复了该问题:
I got similar errors and this awkward looking thing, documented here, fixed it for me:
-Djavax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom=com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl
我正在macOS上使用此Java版本:
I'm using this java version on macos:
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
-Djaxp.debug = 1的stderr帮助我找到了这个
The stderr from -Djaxp.debug=1 helped me find this:
JAXP: Looking up system property 'javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom'
JAXP: The property is undefined.
所以我准确地给出了它所要的内容,一切都很高兴,诸如此类:
So I gave it exactly what it was asking for and it got all happy and such:
JAXP: Looking up system property 'javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom'
JAXP: The value is 'com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl'
JAXP: createInstance(com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl)
JAXP: loaded com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl from jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Hom e/jre/lib/rt.jar!/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.class
JAXP: factory 'com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl' was found for http://java.sun.com/jaxp/xpath/dom
我对:uri语法感到好奇,因为在没有:uri的情况下,以下工作正常.那么为什么XPath要求这样做,而其他的不需要?
I am curious about the :uri syntax, because the following work just fine without :uri. So why does XPath require this and these others don't?
-Dcom.sun.org.apache.xml.internal.dtm.DTMManager=com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
这篇关于找不到XPathFactoryImpl错误(使用myBatis)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!