Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to expose a dependency of a dependency in a maven project
    primarykey
    data
    text
    <p>I have a maven web application that is using a jar I created and is referenced as a dependency in my pom file.</p> <p>The jar file I created has another jar file as a dependency.</p> <p>When I deploy the web application, it says that a class in the dependency of the jar file I created cannot be found.</p> <p>The only way to work around this was to add the dependency of the jar file as a dependency of the war file. This seems unnecessary.</p> <p>Is there a way I can configure the war file to be able to see the classes defined in a dependency of a dependent jar file?</p> <p>my jar pom file looks like: The dependency that has the class that can't be found is the the QRS one.</p> <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;group&lt;/groupId&gt; &lt;artifactId&gt;artifact&lt;/artifactId&gt; &lt;packaging&gt;jar&lt;/packaging&gt; &lt;version&gt;1.0.7&lt;/version&gt; &lt;name&gt;name&lt;/name&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;group2&lt;/groupId&gt; &lt;artifactId&gt;QRS&lt;/artifactId&gt; &lt;version&gt;8.1&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&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.3&lt;/version&gt; &lt;configuration&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;classpathPrefix&gt;lib&lt;/classpathPrefix&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-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;copy-dependencies&lt;/id&gt; &lt;phase&gt;prepare-package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;copy-dependencies&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;outputDirectory&gt;${project.build.directory}/classes/lib&lt;/outputDirectory&gt; &lt;overWriteReleases&gt;false&lt;/overWriteReleases&gt; &lt;overWriteSnapshots&gt;false&lt;/overWriteSnapshots&gt; &lt;overWriteIfNewer&gt;true&lt;/overWriteIfNewer&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>my war pom looks like:</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;group&lt;/groupId&gt; &lt;artifactId&gt;artifact&lt;/artifactId&gt; &lt;version&gt;1.0.7&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>and the war plug in is configured:</p> <pre><code> &lt;plugin&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;version&gt;2.2&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;version&gt;2.2&lt;/version&gt; &lt;configuration&gt; &lt;warName&gt;${project.name}-${project.version}-${env}&lt;/warName&gt; &lt;webResources&gt; &lt;resource&gt; &lt;directory&gt;src/main/webapp/WEB-INF&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;include&gt;jboss-web.xml&lt;/include&gt; &lt;include&gt;web.xml&lt;/include&gt; &lt;targetPath&gt;/WEB-INF&lt;/targetPath&gt; &lt;/resource&gt; &lt;/webResources&gt; &lt;warSourceExcludes&gt;**/toAggregateAndRemove/**&lt;/warSourceExcludes&gt; &lt;goal&gt;war:manifest&lt;/goal&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt; &lt;/manifest&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload