You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Luke Taylor <ne...@freesurf.ch> on 2006/02/02 14:18:23 UTC

nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Hi all,

I'm trying to get a maven 2 build working for our project so that I can
make use of the latest snapshot releases.

I've run into a problem that we had before, due to the log4j classes
being ahead of nlog4j on the classpath. The problem seems to be the one
discussed here (the same symptoms exactly):

http://www.nabble.com/Re:-upgrading-to-nlog4j.1.2.17-p1089156.html

We got round it in maven 1 by altering the order of the dependency list
to put nlog4j ahead of log4j, but with Maven 2 this doesn't work. The
test classpath always has log4j listed first and we always get the
exception.

Has anyone else been using an embedded apacheds server in a build and
found a more permanent solution to the issue with slf4j/nlog4j ?

cheers,

Luke.


-- 
 Luke Taylor.                      Monkey Machine Ltd.
 PGP Key ID: 0x57E9523C            http://www.monkeymachine.ltd.uk


Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Luke Taylor <ne...@freesurf.ch>.
I've just come across Maven 2's "exclusions" pom element for
dependencies might solve my problem:

http://docs.codehaus.org/display/MAVEN/Transitive+Dependencies+Filtering

-- 
 Luke Taylor.                      Monkey Machine Ltd.
 PGP Key ID: 0x57E9523C            http://www.monkeymachine.ltd.uk


Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Luke Taylor <ne...@freesurf.ch>.
Thanks again, Emmanuel (and Ceki).

I think I was wrong about the nlog4j in the core ADS pom, as it is set
to "provided" scope so shouldn't be downloaded.

Everything seems to be working now since I added the maven "excludes"
tag and an slf4j-log4j12 dependency to our build. I'm not exactly sure
why, but I'm not complaining :).

Keep up the good work and good luck with the release.

Luke.


-- 
 Luke Taylor.                      Monkey Machine Ltd.
 PGP Key ID: 0x57E9523C            http://www.monkeymachine.ltd.uk


Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Maarten Bosteels <m....@pandora.be>.
Emmanuel Lecharny wrote:

>On Thu, 2006-02-02 at 15:42 +0000, Luke Taylor wrote:
>  
>
>>Hi Emmanuel,
>>
>>The problem is that log4j is a dependency of many other projects (e.g.
>>Spring) which we depend on, and maven2 ends up with it in the classpath
>>anyway.
>>    
>>
>
>Yeah, we have experienced such a problem lately with Spring...
>Sorry, I thought you were working with a 0.9.3 or something like that.
>
><snip/>
>  
>
As far as I know, spring only has a build-time dependency on log4j,  no 
runtime dependency.
At runtime it uses jakarta-commons-logging,  (and whatever logging 
framework is found by JCL)

Maarten

Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Emmanuel Lecharny <el...@gmail.com>.
On Thu, 2006-02-02 at 15:42 +0000, Luke Taylor wrote:
> Hi Emmanuel,
> 
> The problem is that log4j is a dependency of many other projects (e.g.
> Spring) which we depend on, and maven2 ends up with it in the classpath
> anyway.

Yeah, we have experienced such a problem lately with Spring...
Sorry, I thought you were working with a 0.9.3 or something like that.

<snip/>

>  The apache-ds core still has a
> dependency on nlog4j in the latest Maven 2 file:
> 
> https://svn.apache.org/repos/asf/directory/trunks/apacheds/core/pom.xml

It should not... Normally, dependency like these are marked with a scope
restricted to tests. We have to check that.


> 
> I *think* (perhaps a Maven 2 expert can confirm), that if nlog4j is
> marked as optional in the pom.xml

Exactly. But I'm not a m2 expert, so ...

<snip/>
>  I
> think it's likely to recur when more people start adding apache-ds jar
> files to their builds.

yep. 

> 
> I could be completely wrong of course - in fact I'd be pleased if
> there's a simple workaround.

well, I wish I have this workaround. We will try to find out a way to
help you ! Just be patient, we are quite busy atm...

-- 
Emmanuel Lécharny
www.iktek.com



Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Luke Taylor <ne...@freesurf.ch>.
Hi Emmanuel,

The problem is that log4j is a dependency of many other projects (e.g.
Spring) which we depend on, and maven2 ends up with it in the classpath
anyway.

I don't think it's anything to do with the ADS version. I already have
the latest source and I'm building our project with the latest snapshots
from

http://svn.apache.org/maven-snapshot-repository/org/apache/directory/server/org.apache.ldap.server.core/0.9.4-SNAPSHOT/

which were built today, it seems. The apache-ds core still has a
dependency on nlog4j in the latest Maven 2 file:

https://svn.apache.org/repos/asf/directory/trunks/apacheds/core/pom.xml

So if I am building another project which uses apache-ds, I get both
log4j and nlog4j appearing in the test classpath which is a recipe for
trouble.

I *think* (perhaps a Maven 2 expert can confirm), that if nlog4j is
marked as optional in the pom.xml, then it won't automatically be added
to my transitive dependencies list and I can then manually add whatever
version of slf4j I want to use. This is a particularly nasty problem and
hard to work out what's going on when you first come across it so I
think it's likely to recur when more people start adding apache-ds jar
files to their builds.

I could be completely wrong of course - in fact I'd be pleased if
there's a simple workaround.

Luke.





Emmanuel Lecharny wrote:
> Hi Luke, Ceki,
> 
> I think that the pb come from the ADS version you are using. We now have
> cleaned ADS, in order to avoid a log4j.jar dependency. This will be the
> 1.0-RC1 version, if you can wait a little bit.
> 
> Otherwise, you can build a fresh jar from the trunks in order to fix
> your problem (I hope it will !).
> 
> Regards, 
> 

-- 
 Luke Taylor.                      Monkey Machine Ltd.
 PGP Key ID: 0x57E9523C            http://www.monkeymachine.ltd.uk


Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Emmanuel Lecharny <el...@gmail.com>.
Hi Luke, Ceki,

I think that the pb come from the ADS version you are using. We now have
cleaned ADS, in order to avoid a log4j.jar dependency. This will be the
1.0-RC1 version, if you can wait a little bit.

Otherwise, you can build a fresh jar from the trunks in order to fix
your problem (I hope it will !).

Regards, 

-- 
Emmanuel Lécharny
www.iktek.com



Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Luke Taylor <ne...@freesurf.ch>.

Ceki Gülcü wrote:
> 
> Luke,
> 
> Have you tried using the vanilla log4j binding instead of NLOG4J? That
> should solve the conflict. The vanilla log4j binding is included in the
> SLF4J distribution.
> 
> I hope this helps,
> 

Thanks for the quick reply. I'm not quite sure how to do that though...
I'm only aware of it as an internal problem within a binary ApacheDS
distribution. Is there something I can set at runtime to change the
behaviour?

nlog4j is specified as a build dependency in the apache-ds core pom.xml
(and presumably other parts of the server) which I believe is how it
ends up in the classpath (we don't us it in the project at all). So do
you mean that if I can prevent nlog4j from being added as a dependency
and add slf4j-log4j12 instead, then that should do it?

Perhaps nlog4j could be marked as an "optional" jar in the apache-ds
pom.xml files to prevent it being downloaded as a transitive dependency?

Luke.


-- 
 Luke Taylor.                      Monkey Machine Ltd.
 PGP Key ID: 0x57E9523C            http://www.monkeymachine.ltd.uk


Re: nlog4j/log4j conflict problem (IncompatibleClassChangeError) with embedded server

Posted by Ceki Gülcü <li...@qos.ch>.
Luke,

Have you tried using the vanilla log4j binding instead of NLOG4J? That 
should solve the conflict. The vanilla log4j binding is included in the 
SLF4J distribution.

I hope this helps,

At 02:18 PM 2/2/2006, Luke Taylor wrote:
>Hi all,
>
>I'm trying to get a maven 2 build working for our project so that I can
>make use of the latest snapshot releases.
>
>I've run into a problem that we had before, due to the log4j classes
>being ahead of nlog4j on the classpath. The problem seems to be the one
>discussed here (the same symptoms exactly):
>
>http://www.nabble.com/Re:-upgrading-to-nlog4j.1.2.17-p1089156.html
>
>We got round it in maven 1 by altering the order of the dependency list
>to put nlog4j ahead of log4j, but with Maven 2 this doesn't work. The
>test classpath always has log4j listed first and we always get the
>exception.
>
>Has anyone else been using an embedded apacheds server in a build and
>found a more permanent solution to the issue with slf4j/nlog4j ?
>
>cheers,
>
>Luke.
>
>
>--
>  Luke Taylor.                      Monkey Machine Ltd.
>  PGP Key ID: 0x57E9523C            http://www.monkeymachine.ltd.uk

-- 
Ceki Gülcü