[logback-user] Jetty conflict

Ceki Gülcü ceki at qos.ch
Thu Feb 4 09:41:57 CET 2010


Assuming jetty uses child-first a.k.a. local-first class loading order, I would 
recommend to bundle slf4j and logback jar in your war file.

Jetty used to have the opposite class loading order, i.e. parent-first, but I am 
  under the impression that it changed to local-first class loading in recent 
versions.

BTW, Tomcat uses local-first class loading by default.

HTH,

On 04/02/2010 9:28 AM, Aleksey Didik wrote:
> Hello Ceki,
> Thanks for explanation. It's clear now.
> I'll try to make something with this situation.
>
> Aleksey.
>
>
> 03.02.2010 21:46, Ceki Gulcu пишет:
>>
>> Hello Aleksey,
>>
>>
>> I am not totally surprised by what you describe. According to the java
>> laguage specification (JLS) two classes loaded by distinct class
>> loaders are deemed incompatible even if the classes are bitwise
>> identical.
>>
>> When the jetty class loader loads ch.qos.classic.Logger it also needs
>> to load org.slf4j.Logger which it can, and does. When the
>> ch.qos.classic.Logger is returned to your web-application as a
>> org.slf4j.Logger as requested by your web-application, the returned
>> Logger is not compatible with the expected Logger, even if they are
>> both of type org.slf4j.Logger. Your web-application expects it to be
>> loaded by the web-app's class loader but the returned instance is loaded
>> by the jetty class loader, hence the error you observe.
>>
>> HTH,
>>
>> On 03.02.2010 18:36, Aleksey Didik wrote:
>>> Hello,
>>> I have caught a problem of using embedded Jetty and slf4j, may be you
>>> can help me.
>>>
>>> Jetty tell me this one:
>>>
>>> java.lang.LinkageError: loader constraint violation: when resolving
>>> method
>>> "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;"
>>>
>>> the
>>> class loader (instance of org/eclipse/jetty/webapp/WebAppClassLoader) of
>>> the current class, org/slf4j/LoggerFactory, and the class loader
>>> (instance of sun/misc
>>> /Launcher$AppClassLoader) for resolved class,
>>> org/slf4j/impl/StaticLoggerBinder, have different Class objects for the
>>> type org/slf4j/ILoggerFactory used in the
>>> signature [main o.e.j.u.l.Slf4jLog.warn:111]
>>>
>>> I have next jars:
>>>
>>> Embedded Jetty classpath:
>>> slf4j-api-1.5.10.jar
>>> logback-classic-0.9.18.jar
>>>
>>> War libs:
>>> slf4j-api-1.5.10.jar
>>>
>>> But I add
>>> slf4j-api-1.5.10.jar
>>> logback-classic-0.9.18.jar
>>> to WAR libs and delete
>>> logback-classic-0.9.18.jar
>>> from jetty classpath, all work fine.
>>>
>>> Best regards,
>>> Aleksey Didik
>>
>> _______________________________________________
>> Logback-user mailing list
>> Logback-user at qos.ch
>> http://qos.ch/mailman/listinfo/logback-user
>>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user



More information about the Logback-user mailing list