title: maven - referenced libraries not found in packaged jar
body: <p>When I <code>mvn clean package</code> the project and run it with <code>java -jar target/project.jar</code> it throws an error that it cannot find some class from an external jar.</p>
  
  <p><em>Steps taken</em></p>
  
  <ol>
  <li><p>All external jars are in a folder of my project: <code>/jars</code> or <code>/jars/morejars/</code></p></li>
  <li><p>Adding the jars to the build path: In Eclipse I right click on <code>project</code>, go to <code>build path</code> and select <code>add external archives</code>. I can see that eclipse creates a library folder "referenced libraries" below the "Maven dependencies" folder. When I check <code>project</code> -> <code>Properties</code> -> <code>Java Build Path</code> -> <code>Libraries</code> I can see all the imported jars.</p></li>
  </ol>
  
  <p>Some of those external jars are described as <code>&lt;dependency&gt;</code> (with <code>&lt;systemPath</code>) in <code>pom.xml</code>, so they will not be seen in <code>Referenced Libraries</code> but in <code>Maven dependencies</code> (interestingly, the class that cannot be found when running my packaged project is in an external jar that doesn't reside in <code>Referenced Libraries</code> but <code>Maven dependencies</code>)</p>
  
  <p>e.g.</p>
  
  <pre><code>       &lt;dependency&gt;
              &lt;groupId&gt;external.jar.groupid&lt;/groupId&gt;
              &lt;artifactId&gt;external.jar.artifactid&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${basedir}/jars/external-jar.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <ol start="3">
  <li><p>Use the maven assembly plugin (as described <a href="https://stackoverflow.com/a/1729094/5379182">here</a>), this is my full <code>&lt;build&gt;</code> config:</p>
  
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                &lt;execution&gt;
                  &lt;phase&gt;package&lt;/phase&gt;
                  &lt;goals&gt;
                    &lt;goal&gt;single&lt;/goal&gt;
                  &lt;/goals&gt;
                &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                &lt;descriptorRefs&gt;
                  &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                &lt;/descriptorRefs&gt;
              &lt;/configuration&gt;
            &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre></li>
  <li><p>Run <code>mvn clean package</code> -> <code>BUILD SUCCESS</code></p></li>
  <li><p><code>java -jar target/project.jar</code> -> Cannot find <code>some.class</code> from <code>external.jar</code></p></li>
  </ol>
  
  <p>Thanks for the help</p>