You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sean McNamara <ta...@yahoo.com> on 2006/05/03 20:16:43 UTC

Transitive dependencies and duplicate jars....

I'm fighting with some classloading issues, and am hoping someone can help me resolve this.

We have an application composed of a WAR, several EJB jars, and some shared support jars.

Following the J2EE best practices, the shared jars are packaged at the EAR level, and the EJB jar contains references to those jars in it's MANIFEST.MF via the Class-Path parameter.

For the WAR, the jar dependencies are listed <scope>provided</provided>.  The WAR also has several other dependencies which are bundled in it's WEB-INF/lib directory.

The problem I'm having involves transitive dependencies.  There are some support libraries such as xml-apis.jar that are apparently used by various jars.  These libraries are ending up at both the EAR level, and also the WEB-INF/lib level.  At runtime, I'm getting the dreaded "ClassCastException" that usually occurs when there is a mismatch in classfiles/loaders.

I need to get rid of the duplicates in the WEB-INF/lib directory, but am not sure quite how to accomplish this.  Can anyone provide some direction?

Thanks.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Transitive dependencies and duplicate jars....

Posted by Wendy Smoak <ws...@gmail.com>.
On 5/3/06, Sean McNamara <ta...@yahoo.com> wrote:

> I need to get rid of the duplicates in the WEB-INF/lib directory, but am not sure quite how to accomplish this.  Can anyone provide some direction?

http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

Usually you do this with <exclusions>.  Sometimes it's hard to figure
out where the unwanted jars are coming from, though.  Running mvn with
-X on the command line should output enough information.

(I've been known to cheat and just declare the offending jars as
<scope>provided</scope> dependencies in the module with the problem. 
That will be the "closest" definition and it will override whatever
else is in the dependency graph.)

HTH,
--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Transitive dependencies and duplicate jars....

Posted by Sean McNamara <ta...@yahoo.com>.
Thanks Wayne & Wendy for your comments, they were very helpful.

Wayne: I don't think this is necessarily a bug.  I have a two different dependencies:  A.jar depends on Z.jar, and B.jar also depends on Z.jar.  I'm marking A.jar as "provided" and including it in the manifest classpath, which also included Z.jar in the manifest classpath.

Since B.jar is packaged in the war, and also depends on Z.jar, Z.jar shows up in WEB-INF/classes as well.

At least that's my guess as to what's happening.


Thanks again for the helpful tips!

----- Original Message ----
From: Wayne Fay <wa...@gmail.com>
To: Maven Users List <us...@maven.apache.org>
Sent: Wednesday, May 3, 2006 1:24:12 PM
Subject: Re: Transitive dependencies and duplicate jars....

Quickest/easiest fix is probably to add those dependencies to your WAR
pom with scope provided.

Sounds like a possible bug... if a dep is declared as scope provided,
then I'd think its dependencies should also come in as provided. Are
you saying these are instead coming in as compile scope, and being
included in WEB-INF/lib?

Wayne

On 5/3/06, Sean McNamara <ta...@yahoo.com> wrote:
> I'm fighting with some classloading issues, and am hoping someone can help me resolve this.
>
> We have an application composed of a WAR, several EJB jars, and some shared support jars.
>
> Following the J2EE best practices, the shared jars are packaged at the EAR level, and the EJB jar contains references to those jars in it's MANIFEST.MF via the Class-Path parameter.
>
> For the WAR, the jar dependencies are listed <scope>provided</provided>.  The WAR also has several other dependencies which are bundled in it's WEB-INF/lib directory.
>
> The problem I'm having involves transitive dependencies.  There are some support libraries such as xml-apis.jar that are apparently used by various jars.  These libraries are ending up at both the EAR level, and also the WEB-INF/lib level.  At runtime, I'm getting the dreaded "ClassCastException" that usually occurs when there is a mismatch in classfiles/loaders.
>
> I need to get rid of the duplicates in the WEB-INF/lib directory, but am not sure quite how to accomplish this.  Can anyone provide some direction?
>
> Thanks.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Transitive dependencies and duplicate jars....

Posted by Wayne Fay <wa...@gmail.com>.
Quickest/easiest fix is probably to add those dependencies to your WAR
pom with scope provided.

Sounds like a possible bug... if a dep is declared as scope provided,
then I'd think its dependencies should also come in as provided. Are
you saying these are instead coming in as compile scope, and being
included in WEB-INF/lib?

Wayne

On 5/3/06, Sean McNamara <ta...@yahoo.com> wrote:
> I'm fighting with some classloading issues, and am hoping someone can help me resolve this.
>
> We have an application composed of a WAR, several EJB jars, and some shared support jars.
>
> Following the J2EE best practices, the shared jars are packaged at the EAR level, and the EJB jar contains references to those jars in it's MANIFEST.MF via the Class-Path parameter.
>
> For the WAR, the jar dependencies are listed <scope>provided</provided>.  The WAR also has several other dependencies which are bundled in it's WEB-INF/lib directory.
>
> The problem I'm having involves transitive dependencies.  There are some support libraries such as xml-apis.jar that are apparently used by various jars.  These libraries are ending up at both the EAR level, and also the WEB-INF/lib level.  At runtime, I'm getting the dreaded "ClassCastException" that usually occurs when there is a mismatch in classfiles/loaders.
>
> I need to get rid of the duplicates in the WEB-INF/lib directory, but am not sure quite how to accomplish this.  Can anyone provide some direction?
>
> Thanks.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org