8

Spring 3.1.1.RELEASE with Apache Maven 3.0.3 and Maven Shade plugin 1.6.

Using the mvn shade plugin to package the artifact in an uber-jar, including its dependencies:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
        <phase>package</phase>
        <goals>
            <goal>shade</goal>
        </goals>
        <configuration>
            <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <mainClass>com.MyApplication</mainClass>
                </transformer>
            </transformers>
        </configuration>
    </execution>
</executions>

Seems to package just fine but on execution complains of Spring NamespaceHandler issues:

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

This applies to both the util and p-namespaces, but expect it's not limited to these:

xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"

If I rewrite the property or list (util) longhand the issues disappear.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Andrew Eells
  • 735
  • 12
  • 30

1 Answers1

22

Try adding an AppendingTransformer to your config. The example specifically mentions this as being useful for Spring handlers.

user944849
  • 14,524
  • 2
  • 61
  • 83
  • This helped me also, didn't work with maven-assembly-plugin, didnt work with shade, but worked with your answer. Can you, please, explain what's happening here and why this worked? – drakonli Aug 25 '18 at 17:08