Hi,

I had the following error when trying to execute my Spring Batch project jar file :
Code:
15:34:38,673  INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [spring-batch.xml]
15:34:59,508 ERROR CommandLineJobRunner:355 - Job Terminated in error: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [spring-batch.xml]

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [spring-batch.xml]

	at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416)
	at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
...
After some searching, my problem can be solved by copying the META-INF/spring.handlers and the META-INF/spring.schemas of the Spring jar into the META-INF of my jar.

I'm aware that this problem can occur in some setup when a jar is built with all his dependencies included (ex. maven jar-with-dependencies) but, I'm wondering why I have this problem if the Spring jars are in a separate "lib" folder?

Notes :
  • All Spring jars are in my classpath with the same version (Spring 3.1.0.RELEASE, Spring Batch 2.1.8.RELEASE)
  • Launch command : java -jar my-batch-project-1.0-SNAPSHOT.jar spring-batch.xml job
  • The jar is created by maven with maven-jar-plugin and maven-dependency-plugin that copies the dependencies into the lib folder.


thank you