views:

537

answers:

2

EDIT:

I am basically running into the following documented issue. I am using the maven assembly plugin to generate a jar file that includes my dependencies so that my project can be run from a single file. However, the jar file is not being built properly it seems. The below was an attempt to try and work around the issue. Has anyone run into this before?

So I am trying to build a jar file that includes all of my dependencies packed and my project artifact jar unpacked.

I tried doing something to the effect of

<assembly>
  <id>jar-with-dependencies-packed</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <dependencySet>
      <unpack>true</unpack>
      <unpackOptions>
          <includes>
              <include>artifactname</include>
          </includes>
      </unpackOptions>
      <scope>runtime</scope>
      <outputDirectory>lib</outputDirectory>
    </dependencySet>
  </dependencySets>
</assembly>

However, the resulting jar file includes only the META-INF directory... When I say to unpack, but unpack only my includes, does that mean the original jar files aren't included?

When I run the jar I receive the following

Exception in thread "main" java.lang.ExceptionInInitializerError
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 [applicationContext.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.fac

tory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)

A: 

The problem was that I was using the "spring-util" namespace in my applicationContext. Although I had spring-beans as a project dependency and therefore it was added to my classpath, the namespace handler could not be resolved. Since I only use the util:list on one occasion I decided to remove it from the context. From there I was able to build my jar without issue. I am not sure if the real problem is somewhere in how maven assembly is generating the jar file or if it is a spring issue. Either way, I have a workaround.

predhme
+1  A: 

Had you take a look at onejar-maven-plugin. It does what you want in a straightforward way.

diega
I have not be will certainly do so, thanks!
predhme
It seems that the onejar does exactly what I was originally trying to achieve to solve my issue. Thanks a lot!
predhme