Maven dependencies jar not usable

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)

Answer

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

Leave a Reply

Your email address will not be published. Required fields are marked *