I am getting the following error when I startup Spring web application in Tomcat.
Basically, as the beans.xml file is processed, the following classes are loaded in order.
org.springframework.context.config.ContextNamespaceHandler to process URI http://www.springframework.org/schema/context
org.springframework.beans.factory.xml.UtilNamespaceHandler to process URI http://www.springframework.org/schema/util
org.apache.cxf.jaxws.spring.NamespaceHandler to process URI http://cxf.apache.org/jaxws
org.apache.cxf.transport.http.spring.NamespaceHandler to process URI http://cxf.apache.org/transports/http/configuration
org.springframework.batch.core.configuration.xml.CoreNamespaceHandler to process URI http://www.springframework.org/schema/batch
But when it is loading the above last class for batch URI, the following Exception occurs.
12/28/2017-11:21:47.070 - localhost-startStop-1 - ERROR [org.springframework.web.context.ContextLoader : Line 227]: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is org.springframework.beans.FatalBeanException: Class [org.springframework.batch.core.configuration.xml.CoreNamespaceHandler] for namespace [http://www.springframework.org/schema/batch] does not implement the [org.springframework.beans.factory.xml.NamespaceHandler] interface
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
I looked into the source of all the above classes and found that all of them extend
org.springframework.beans.factory.xml.NamespaceHandlerSupport
which in turn implements
org.springframework.beans.factory.xml.NamespaceHandler
I have checked the jars on classpath and they look fine, containing the above classes and interfaces in respective, expected spring jar files.
Any idea how to resolve this?
Similar questions are here and I have tried whats given there.
Unexpected exception parsing XML document from class path resource [config/FaceBookSimulator.xml];
and
Update
I restarted Tomcat with -verbose:class option to print all classes being loaded form whichever jar files. And I found the following:
12/28/2017-15:01:18.251 - localhost-startStop-1 - DEBUG [org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver : Line 156]: Loaded NamespaceHandler mappings:{
http://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNamespaceHandler,
http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler,
http://cxf.apache.org/transports/http-jetty/configuration=org.apache.cxf.transport.http_jetty.spring.NamespaceHandler,
http://www.w3.org/2006/07/ws-policy=org.apache.cxf.ws.policy.spring.PolicyNamespaceHandler,
http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler,
http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler,
http://cxf.apache.org/jaxws=org.apache.cxf.jaxws.spring.NamespaceHandler,
http://cxf.apache.org/policy=org.apache.cxf.ws.policy.spring.NamespaceHandler,
http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler,
http://cxf.apache.org/transports/jms=org.apache.cxf.transport.jms.spring.NamespaceHandler,
http://cxf.apache.org/transports/http/configuration=org.apache.cxf.transport.http.spring.NamespaceHandler,
http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler,
http://cxf.apache.org/bindings/object=org.apache.cxf.binding.object.spring.NamespaceHandler,
http://cxf.apache.org/ws/addressing=org.apache.cxf.ws.addressing.spring.NamespaceHandler,
http://cxf.apache.org/clustering=org.apache.cxf.clustering.spring.NamespaceHandler,
http://cxf.apache.org/simple=org.apache.cxf.frontend.spring.NamespaceHandler,
http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler,
http://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler,
http://cxf.apache.org/core=org.apache.cxf.bus.spring.NamespaceHandler,
http://cxf.apache.org/jaxrs=org.apache.cxf.jaxrs.spring.NamespaceHandler,
http://cxf.apache.org/binding/coloc=org.apache.cxf.binding.coloc.spring.NamespaceHandler,
http://schemas.xmlsoap.org/ws/2004/09/policy=org.apache.cxf.ws.policy.spring.PolicyNamespaceHandler,
http://www.springframework.org/schema/jms=org.springframework.jms.config.JmsNamespaceHandler,
http://www.springframework.org/schema/batch=org.springframework.batch.core.configuration.xml.CoreNamespaceHandler,
http://www.w3.org/ns/ws-policy=org.apache.cxf.ws.policy.spring.PolicyNamespaceHandler,
http://cxf.apache.org/ws/rm/manager=org.apache.cxf.ws.rm.spring.NamespaceHandler,
http://cxf.apache.org/bindings/soap=org.apache.cxf.binding.soap.spring.NamespaceHandler
}
The class
org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver
is processing:
http://www.springframework.org/schema/batch=org.springframework.batch.core.configuration.xml.CoreNamespaceHandler
The DefaultNamespaceHandlerResolver does not extend NamespaceHandlerSupport ( which implements NamespaceHandler).
If the finding is right, how to resolve this?