XPathFactory#newInstance() failed to create an XPathFactory for the default object 报错解决办法整理

本文解决了一个关于XPathFactory创建失败的问题,该问题出现在部署Web应用程序时。通过移除特定的jar包,如xercesImpl.jar和xml-apis.jar,成功解决了JBoss启动时遇到的错误。同时讨论了多版本jar包冲突的情况。

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: No XPathFctory implementation found for the object model:http://java.sun.com/jaxp/xpath/dom
 javax.xml.xpath.XPathFactory.newInstance

 

将下面两个jar包移除后正常部署

$JBOSS_HOME/lib/endorsed/xercesImpl.jar
$JBOSS_HOME/lib/endorsed/xml-apis.jar

-----------------------华丽的分割线----------------------------

我按照上述办法解决了,Jboss正常启动;下面的论述也有帮助,总共Jboss目录下有四个jar,可能是和maven管理下的同名jar包重复,或者版本不同,导致的。至于删除哪几个根据具体情况而定。

-----------------------华丽的分割线----------------------------

Caused by: 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: No XPathFctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom

 

Recently I have deployed my web project under Eclipse using tomcat servlet container and found the following error that caused my web application fail to starup:

ERROR 2009-09-04 16:13:13,895 org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3768) - Exception sending context initialized event to listener instance of class web.context.impl.ContextConfigListener
java.lang.ExceptionInInitializerError
        at service.impl.ElasticPathServiceImpl.init(ElasticPathServiceImpl.java:81)
        at web.context.impl.ContextConfigListener.doPathConfig(ContextConfigListener.java:125)
        at web.context.impl.ContextConfigListener.contextInitialized(ContextConfigListener.java:61)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:448)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: 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: No XPathFctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom
        at javax.xml.xpath.XPathFactory.newInstance(Unknown Source)
        at org.apache.solr.core.Config.(Config.java:52)
        ... 18 more
Sep 4, 2009 4:13:13 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Sep 4, 2009 4:13:13 PM org.apache.catalina.core.StandardContext start

 

After days of heavy drinking and being miserable about this I have finally found the cause of the issue:

Multiple versions of the xalan.jar in libs

This was due to maven smartness that resolved one of my dependencies to use version 2.60 and the other to use 2.7.0 which were deployed under one tomcat and cause the problem.

 

After some more research on the internet I have found that the same issue appears when the following jar have multiple versions in libs:

xalan
xerces
xml-apis

Or if an implementation of XML api such as xalan is missing.

I think maven is great tool, but you need to use it responsibly.

Peace out...


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值