I am working on a backend Maven3 project. I am building an uber JAR which contains several other JAR files and resources. That worked pretty good. But than I tried to run the JAR file with
java -jar <uber-super-duper-jar-file>
I got this Exception:
INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml] Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
This is because I have several Spring Jar in my dependencies. Some of the spring jars contain meta info files with the same name. To avoid that some meta files are overridden you have to merge it. If you are using the maven shade plugin to build your JAR file you can do the merge with this xml snippet:
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer>
Here is a more detailed description:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
Thanks a lot! It solved my problem! Best wishes!
Solved my issue as well! Thank you!
Solved my problem as well, thank you
Thanks a lot!
thanks
what to do if I dont use a maven shade plugin ?
I don’t know. But let me know when you find out.
Thanks a lot ! fix it.
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
NO solved my problem,
NO solved my problem,
even solved my problem too….Thanks 🙂