org.apache.xerces.jaxp.DocumentBuilderFactoryImpl与javax.xml.parsers.DocumentBuilderFactory不兼容

时间:2013-12-05 16:10:27

标签: java xml spring

当我尝试在WAS8.0中启动我的应用程序时遇到以下问题。

[

12/5/13 16:01:53:633 GMT] 00000010 ContextLoader I org.springframework.web.context.ContextLoader initWebApplicationContext Root WebApplicationContext: initialization started
[12/5/13 16:01:53:736 GMT] 00000010 XmlWebApplica I org.springframework.context.support.AbstractApplicationContext prepareRefresh Refreshing Root WebApplicationContext: startup date [Thu Dec 05 16:01:53 GMT 2013]; root of context hierarchy
[12/5/13 16:01:53:821 GMT] 00000010 XmlBeanDefini I org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions Loading XML bean definitions from class path resource [XXX.xml]
[12/5/13 16:01:53:858 GMT] 00000010 ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
                                 org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [XXX.xml]; nested exception is java.lang.ClassCastException: <b>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl incompatible with javax.xml.parsers.DocumentBuilderFactory</b>
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

1 个答案:

答案 0 :(得分:1)

确保将最新版本的Xerces带入类路径。 DocumentBuilderFactoryImpl实施javax.xml.parsers.DocumentBuilderFactory,如here所示。

正如@Augusto所说,确保你没有多个版本的Xerces。