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

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...


你可能感兴趣的:(Jboss)