I’m using the maven-shade-plugin to build a standalone spring-based java application.
Have you ever seen this complaint from spring:
Well, here’s the thing. Inside all those spring jars, in the META-INF directory you’ll see a file
and another file
Everyone of the spring jars, spring-core and spring-context and spring-aop and so on contains a directory META-INF which contains spring.handlers and spring.schemas files. Most or all of them also have the particular schema file contained as well — this lets you have your spring contexts validated even if you’re running offline.
Here’s what the spring.schemas file looks like if you open up spring-aop-3.0.2.RELEASE.jar and have a look:
http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
http\://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
Notice you do NOT see anything about spring-context or spring-util or spring-task … and so on.
Now the maven-shade-plugin basically expands the jars and rewrites them into the work directory before jarring everything back up again. This normally works fine when you don’t have naming and pathing COLLISIONS, like you do with these schema files. So whichever spring jar was processed last by maven-shade will have its META-INF/* contents written into the final jar you’re creating, overwriting any other content with the same name.
So if you’re using a spring context file that looks something like this:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context :annotation-config />
<util :properties id="defaultProperties"
location="classpath:/spring/defaultScraperExecution.properties"/>
</beans>
…you will get the complaint mentioned in the title of this blog entry. Spring can’t find the namespace handler for “util”, because it is not mentioned in the META-INF/spring.schemas that result in the final product.
Here’s the solution – you need to take advantage of the example in the maven-shade-plugin page and do this in your configuration section:
<transformers>
<!--
must be SURE to do this with both spring.handlers and spring.schemas. otherwise
you won't be able to use them in the spring config files.
-->
<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>
</transformers>
</configuration>
The maven-shade-plugin will append the contents of all META-INF/spring.schemas and META-INF/spring.handlers files it finds during the expansion.

Howdy there,just found your web-site when i google something and wonder what webhosting do you use for your wordpress,the speed is more faster than my website, i really need to know it.will back to check it out,i appreciate it!
[Translate]
Your IP address (61.219.107.164) says you are coming from Taiwan, is that so? Or are you coming in from some TOR connection?
I support my own webserver. I’m in Bulgaria.
[Translate]
I have visited this blog by accident, but I found it quite interesting. You’re doing a good job (and most importantly it’s free). A greeting.
[Translate]
csak igy tovabb
[Translate]
Brilliant, it runs fairly wonderful. Thanks
[Translate]
Amiable fill someone in on and this fill someone in on helped me alot in my college assignement. Gratefulness you seeking your information.
[Translate]
Genial fill someone in on and this fill someone in on helped me alot in my college assignement. Thanks you for your information.
[Translate]
Hey very nice site!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds also…I’m happy to find a lot of useful information here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .
[Translate]
This was a really useful tip; I’ve linked to this post from StackOverflow.
[Translate]
Never seen such cool publish. I just read it all the way to the end. Have them coming. Now you appear on my personal weblog .
[Translate]