You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Désilets, Alain <Al...@nrc-cnrc.gc.ca> on 2018/07/05 14:35:01 UTC

Generate a WAR that depends on JAR that depends on JAR

I am developing a system that consists of two Maven projects:


  *   dedupster-core
  *   dedupster-apps

See the two attached poms.

The core project is packaged as JAR, using the maven-assembly-plugin with a jar-with-dependencies descriptor ref. When I do mvn install on that project, I get two JARS:


  *   dedupster-core-0.0.1-SNAPSHOT.jar
  *   dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar

The second of those is a self-contained jar that can be run at the command line.

The apps project is packaged as a WAR file, and it has a dependency on dedupster-core. When I run mvn install on that project, I get a single WAR file and a jar-with-depencies:



  *   dedupster-apps-0.0.1-SNAPSHOT-jar-with-dependencies.jar
  *   dedupster-apps-0.0.1-SNAPSHOT.war

Then, when I go to Eclipse and dur Run as > Run on Server on the dedupster-apps project, I get:

   NoClassDefFoundError: ca/nrc/dtrc/dedupster/BugReport

My understanding is that NoClassDefFoundError is different from ClassNotFoundException, and that It means that the class was present, but one of the classes that it depends on was absent.

Indeed, when I do a ‘tar tvf on dedupster-apps-0.0.1-SNAPSHOT.war’, I see that WEB-INF/lib contains dedupster-core-0.0.1-SNAPSHOT.jar as opposed to dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar. In other words, it doesn’t contain any of the dependencies that deduspter-core depends on.

So the next thing I tried was to manually copy the dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar over dedupster-core-0.0.1-SNAPSHOT.jar, then redo ‘mvn install’ on the apps project, and restart it in the server. But I still got the same error.

I am at my wits’ end with this and would really appreciate any help that can be provided.

Thx.

Alain Désilets


Re: Generate a WAR that depends on JAR that depends on JAR

Posted by Anders Hammar <an...@hammar.net>.
I would strongly suggest against using jar-with-dependencies jars. You
should let Maven do its dependency management job and include the required
dependencies as jar files instead. And if a class is still missing you
should hunt down what dependency is missing.

/Anders

On Thu, Jul 5, 2018 at 9:02 PM Désilets, Alain <
Alain.Desilets@nrc-cnrc.gc.ca> wrote:

> I am developing a system that consists of two Maven projects:
>
>
>
>    - dedupster-core
>    - dedupster-apps
>
>
>
> See the two attached poms.
>
>
>
> The core project is packaged as JAR, using the maven-assembly-plugin with
> a jar-with-dependencies descriptor ref. When I do mvn install on that
> project, I get two JARS:
>
>
>
>    - dedupster-core-0.0.1-SNAPSHOT.jar
>    - dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar
>
>
>
> The second of those is a self-contained jar that can be run at the command
> line.
>
>
>
> The apps project is packaged as a WAR file, and it has a dependency on
> dedupster-core. When I run mvn install on that project, I get a single WAR
> file and a jar-with-depencies:
>
>
>
>    - dedupster-apps-0.0.1-SNAPSHOT-jar-with-dependencies.jar
>    - dedupster-apps-0.0.1-SNAPSHOT.war
>
>
>
> Then, when I go to Eclipse and dur Run as > Run on Server on the
> dedupster-apps project, I get:
>
>
>
>    NoClassDefFoundError: ca/nrc/dtrc/dedupster/BugReport
>
>
>
> My understanding is that NoClassDefFoundError is different from
> ClassNotFoundException, and that It means that the class was present, but
> one of the classes that it depends on was absent.
>
>
>
> Indeed, when I do a ‘tar tvf on dedupster-apps-0.0.1-SNAPSHOT.war’, I see
> that WEB-INF/lib contains dedupster-core-0.0.1-SNAPSHOT.jar as opposed to
> dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar. In other words, it
> doesn’t contain any of the dependencies that deduspter-core depends on.
>
>
>
> So the next thing I tried was to manually copy the
> dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar over
> dedupster-core-0.0.1-SNAPSHOT.jar, then redo ‘mvn install’ on the apps
> project, and restart it in the server. But I still got the same error.
>
>
>
> I am at my wits’ end with this and would really appreciate any help that
> can be provided.
>
>
>
> Thx.
>
>
>
> Alain Désilets
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

Re: Generate a WAR that depends on JAR that depends on JAR

Posted by Désilets, Alain <Al...@nrc-cnrc.gc.ca>.
Update…

I extracted the content of the ‘apps’ war file using ‘jar -xvf’, then listed the files in the ‘core’ jar that was extracted under ‘WEB-INF/lib’ directory. And it seems to indeed be the jar with dependancies, since it contains not just the classes from the dedupster-core project, but also all classes that it depends on.

So I am really puzzled as to why Tomcat is not able to find those classes.

Alain

From: "Désilets, Alain" <Al...@nrc-cnrc.gc.ca>
Date: Thursday, July 5, 2018 at 10:34 AM
To: "users@maven.apache.org" <us...@maven.apache.org>
Subject: Generate a WAR that depends on JAR that depends on JAR

I am developing a system that consists of two Maven projects:


  *   dedupster-core
  *   dedupster-apps

See the two attached poms.

The core project is packaged as JAR, using the maven-assembly-plugin with a jar-with-dependencies descriptor ref. When I do mvn install on that project, I get two JARS:


  *   dedupster-core-0.0.1-SNAPSHOT.jar
  *   dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar

The second of those is a self-contained jar that can be run at the command line.

The apps project is packaged as a WAR file, and it has a dependency on dedupster-core. When I run mvn install on that project, I get a single WAR file and a jar-with-depencies:



  *   dedupster-apps-0.0.1-SNAPSHOT-jar-with-dependencies.jar
  *   dedupster-apps-0.0.1-SNAPSHOT.war

Then, when I go to Eclipse and dur Run as > Run on Server on the dedupster-apps project, I get:

   NoClassDefFoundError: ca/nrc/dtrc/dedupster/BugReport

My understanding is that NoClassDefFoundError is different from ClassNotFoundException, and that It means that the class was present, but one of the classes that it depends on was absent.

Indeed, when I do a ‘tar tvf on dedupster-apps-0.0.1-SNAPSHOT.war’, I see that WEB-INF/lib contains dedupster-core-0.0.1-SNAPSHOT.jar as opposed to dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar. In other words, it doesn’t contain any of the dependencies that deduspter-core depends on.

So the next thing I tried was to manually copy the dedupster-core-0.0.1-SNAPSHOT-with-dependencies.jar over dedupster-core-0.0.1-SNAPSHOT.jar, then redo ‘mvn install’ on the apps project, and restart it in the server. But I still got the same error.

I am at my wits’ end with this and would really appreciate any help that can be provided.

Thx.

Alain Désilets