title: How to create spring-based executable jar with maven?
body: <p>I have a Maven based Spring-WS client project that I want to package as a single jar.  In eclipse, everything runs properly.  When I try to package it as an executable jar, I get ClassNotFound exceptions since the Spring jars are not included in my application jar.</p>
  
  <p>So I added the <a href="http://maven.apache.org/plugins/maven-shade-plugin/usage.html">maven-shade-plugin</a> to include all my dependencies in my application jar.  When I look at my app jar, I see all the class files from all the dependencies included (all the library jar's are exploded).</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;mainClass&gt;com.cws.cs.Client&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.7&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;shade&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
  
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>My problem is that in the packaging process, my multiple spring dependencies have different <a href="http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/extensible-xml.html#extensible-xml-registration-spring-schemas">META-INF/spring.schemas</a> files that override each other.  Consequently, my final jar has an incomplete spring.schemas file.</p>
  
  <p>So when I try to run my executable jar, I get Spring error messages that files cannot be found since the spring.schemas file is incomplete (the Spring-WS's jar has overriden the Spring-core's spring.schemas file).  </p>
  
  <p>My executable jar's META-INF/spring.schemas:</p>
  
  <pre><code>http\://www.springframework.org/schema/web-services/web-services-1.5.xsd=/org/springframework/ws/config/web-services-1.5.xsd
  http\://www.springframework.org/schema/web-services/web-services-2.0.xsd=/org/springframework/ws/config/web-services-2.0.xsd
  http\://www.springframework.org/schema/web-services/web-services.xsd=/org/springframework/ws/config/web-services-2.0.xsd
  </code></pre>
  
  <p>Instead of Spring-beans.jar META-INF/spring.schemas:</p>
  
  <pre><code>http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
  http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
  http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
  http\://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
  http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
  http\://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd
  http\://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd
  http\://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
  http\://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
  http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
  http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
  http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
  http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
  http\://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
  http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
  </code></pre>
  
  <p>I'm stumped.  I am not sure if/how I can package everything as a single executable jar.  I don't know if this is a shade-plugin configuration issue, or if I am trying to do something impossible.  It would not seem correct that I would have to manually create my own spring.schemas file (a concatenation of the others).</p>
  
  <p>I may have jumped the gun a little.  In digging up more info on the shade plugin, I noticed the <a href="http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer">AppendingTransformer</a> that I had previously missed.  However, my concern is how to know which other files are having the same problems?  I've discovered/caught this particular Spring issue.  I have no idea about any other libraries that may be doing something similar...</p>
  
  <p>Any suggestions would be appreciated.</p>