You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joleen Barker <ol...@gmail.com> on 2016/03/04 15:05:12 UTC

What would happen if there were 2 log4j.jar files in the same library

I saw there is log4j-1.2.8-1.jar and log4j-1.2.17.jar in the WEB-INF/lib
directory for a web application and I wonder what happens if there are two
in the same library.

Thank you,

-Joleen

Re: What would happen if there were 2 log4j.jar files in the same library

Posted by Joleen Barker <ol...@gmail.com>.
Thank you. I will make sure there is only one in the lib directory.

-Joleen

On Fri, Mar 4, 2016 at 9:54 AM, Chris Gamache <cg...@gmail.com> wrote:

> Hi Joleen,
>
> You may already know most of this, but just in case:
>
> Inside or outside of tomcat, if you have two classes in the same classpath,
> both with the same class name and package name, it's often hit-or-miss
> which one will get picked. Weird things happen. And different weird things
> happen with different flavours of JVM or the same JVM make on different
> platforms.
>
> Evaluate your dependencies and eliminate the duplicates. This is often
> wickedly difficult to do manually. There are several different dependency
> management tools you can use-- Maven is my choice, but there are others
> like Ivy and Gradle. Sometimes they build and manage dependencies. Other
> times they just manage dependencies.
>
> If you need to have multiple versions of the same class inside your JVM,
> rolling them up using OSGi is a (very complicated but effective, IMO) way
> to handle that.
>
> hope this helps!
>
> CG
>
>
> On Fri, Mar 4, 2016 at 9:05 AM, Joleen Barker <ol...@gmail.com>
> wrote:
>
> > I saw there is log4j-1.2.8-1.jar and log4j-1.2.17.jar in the WEB-INF/lib
> > directory for a web application and I wonder what happens if there are
> two
> > in the same library.
> >
> > Thank you,
> >
> > -Joleen
> >
>

Re: What would happen if there were 2 log4j.jar files in the same library

Posted by Chris Gamache <cg...@gmail.com>.
Hi Joleen,

You may already know most of this, but just in case:

Inside or outside of tomcat, if you have two classes in the same classpath,
both with the same class name and package name, it's often hit-or-miss
which one will get picked. Weird things happen. And different weird things
happen with different flavours of JVM or the same JVM make on different
platforms.

Evaluate your dependencies and eliminate the duplicates. This is often
wickedly difficult to do manually. There are several different dependency
management tools you can use-- Maven is my choice, but there are others
like Ivy and Gradle. Sometimes they build and manage dependencies. Other
times they just manage dependencies.

If you need to have multiple versions of the same class inside your JVM,
rolling them up using OSGi is a (very complicated but effective, IMO) way
to handle that.

hope this helps!

CG


On Fri, Mar 4, 2016 at 9:05 AM, Joleen Barker <ol...@gmail.com>
wrote:

> I saw there is log4j-1.2.8-1.jar and log4j-1.2.17.jar in the WEB-INF/lib
> directory for a web application and I wonder what happens if there are two
> in the same library.
>
> Thank you,
>
> -Joleen
>