Generate a WAR that depends on JAR that depends on JAR

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Generate a WAR that depends on JAR that depends on JAR

alain_desilets

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: [hidden email]
For additional commands, e-mail: [hidden email]

pom-apps.xml (3K) Download Attachment
pom-core.xml (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

alain_desilets
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" <[hidden email]>
Date: Thursday, July 5, 2018 at 10:34 AM
To: "[hidden email]" <[hidden email]>
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

Reply | Threaded
Open this post in threaded view
|

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

Anders Hammar
In reply to this post by alain_desilets
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 <
[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]