2

I encounter below issues when i tried to start my application in 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)

jmj
  • 237,923
  • 42
  • 401
  • 438
Gary
  • 133
  • 1
  • 8
  • 1
    possible duplicate of [Meaning of java.lang.ClassCastException: someClass incompatible with someClass](http://stackoverflow.com/questions/5352550/meaning-of-java-lang-classcastexception-someclass-incompatible-with-someclass) - Meaning, you have the same classes twice in your classpath. Those classes are now provided by the JRE, so be sure not to include any jar that contains them. – Augusto Dec 05 '13 at 16:15

1 Answers1

1

Make sure you bring the latest version of Xerces into the classpath. DocumentBuilderFactoryImpl implements javax.xml.parsers.DocumentBuilderFactory as shown here.

And as @Augusto says, make sure you don't have multiple versions of Xerces either.

Vidya
  • 29,932
  • 7
  • 42
  • 70
  • I also believe it should due to the collision of some jars, especially the XML parsing related jars, such as "Xerces", "pull-parser", so i exclude them in POM and also mark them as "optional", as result, those jars don't appear in the library of the WAR, however, when i use Maven Dependency plugin to analysis it, i found those dependencies have scope of "compile", so they may be still in server(local WAS8.0) when i publish them to server? a little confused. – Gary Dec 05 '13 at 17:13
  • Check both your war and the application server classpath. – Vidya Dec 05 '13 at 17:35
  • I checked the classpath of my WAS v8.0, it's actually the default output folder of my source in workspace, so all the dependencies built by maven are available in WAS v8.0. – Gary Dec 09 '13 at 08:52