1 2 Previous Next 19 Replies Latest reply: Nov 24, 2011 1:56 PM by Thalys de Aguiar Gomes RSS

JBoss-5.1.0.GA Multiple SLF4J bindings

Ivan Hrytsyuk Newbie

Hello,

 

Our application is packed to EAR and uses latest SLF4J for logging.

During startup we see next errors:

 


15:28:09,222 ERROR [STDERR] SLF4J: Class path contains multiple SLF4J bindings.
15:28:09,222 ERROR [STDERR] SLF4J: Found binding in [vfszip:/home/ihrytsyuk/work/ml/jboss/common/lib/slf4j-jboss-logging.jar/org/slf4j/impl/StaticLoggerBinder.class]
15:28:09,222 ERROR [STDERR] SLF4J: Found binding in [vfszip:/home/ihrytsyuk/work/ml-dev/out/exploded/eee.ear/lib/slf4j-log4j12-1.6.1.jar/org/slf4j/impl/StaticLoggerBinder.class] 
15:28:09,222 ERROR [STDERR] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

 


We tried to apply next solution: http://community.jboss.org/message/556031 but without success.

We created next META-INF/jboss-scanning.xml file:

<scanning xmlns="urn:jboss:scanning:1.0">
    <path name="lib/slf4j-log4j12-1.6.1.jar">
        <exclude name="org.slf4j"/>
    </path>
</scanning>

 

Structure of our EAR:

MyApp.ear
|
|--- META-INF
|--- war1.war 
|--- war2.war
|--- lib

 

 

Is there any way how to run it without errors and without removing slf4j-log4j12-1.6.1.jar from ear?

  • 1. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Nikita D Newbie

    Were you able to find a solution for this?

     

    Thank you,

    Nikita

  • 2. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Ivan Hrytsyuk Newbie

    Not yet.

  • 3. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Nikita D Newbie

    It look like this issue has come up a few times already, but without any resolution other than to remove the slf4j jars from the app. See https://jira.jboss.org/browse/JBPAPP-3951.

  • 5. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    David Lloyd Master

    The only fix is to add a jboss-classloading.xml to exclude the slf4j bindings from the visible classpath of the application.  I don't recall the correct formula off the top of my head, but I think the wiki contains this information.

  • 6. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    David Lloyd Master

    Alternatively, you should be able to update the slf4j in the AS to a newer version without ill effect.

  • 7. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Nikita D Newbie

    Hi David,

     

    Thanks for the reply! The response from another JBoss developer on this thread suggests that it's not possible to exclude particular libraries using configuration. I've also read through the classloading docs on the wiki, but as far as I can tell, those configurations change the overall classloading strategy of the application, and I don't have that option.

     

    If I update the slf4j jars in the AS, can I safely just replace the jboss impl with a different impl (to match the version of the slf4j api)?

     

    Thank you,

    Nikita

  • 8. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    jaikiran pai Master

    Nikita D wrote:

     

    Hi David,

     

    Thanks for the reply! The response from another JBoss developer on this thread suggests that it's not possible to exclude particular libraries using configuration.

    If it's a .war file, then try adding the package name (whatever it is for the slf4j library) to the filteredPackages attribute (which is a comma separated list) of WarClassLoaderDeployer in JBOSS_HOME/server/< servername>/deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml file:

     

    <!-- Allow for war local class loaders: in testing -->
       <bean name="WarClassLoaderDeployer" class="org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer">
          <property name="relativeOrder">-1</property>
          <property name="filteredPackages">javax.servlet,org.apache.commons.logging</property>      
       </bean>

     


    See if that works.

  • 9. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Nikita D Newbie

    Thank you for the suggestion. I actually have an ear application, but I tried this anyway to see if it would work for the war inside my ear. Unfortunately, it didn't make any difference -- I still get the same "multiple SLF4J bindings" error.

     

    This is the config I used:

     

       <!-- Allow for war local class loaders: in testing -->
       <bean name="WarClassLoaderDeployer" class="org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer">
          <property name="relativeOrder">-1</property>
          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j</property>     
       </bean>

       <!-- Allow for war local class loaders: in testing -->

       <bean name="WarClassLoaderDeployer" class="org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer">

          <property name="relativeOrder">-1</property>

          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j</property>     

       </bean>

     

    Is there something similar that can be added in "ear-deployer-jboss-beans.xml"? Or something else I could try?

     

    Thank you,

    Nikita

  • 10. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    jaikiran pai Master

    Nikita D wrote:

     

     

     

    This is the config I used:

     

     

       <!-- Allow for war local class loaders: in testing -->
       <bean name="WarClassLoaderDeployer" class="org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer">
          <property name="relativeOrder">-1</property>
          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j</property>     
       </bean>

       <!-- Allow for war local class loaders: in testing -->

       <bean name="WarClassLoaderDeployer" class="org.jboss.web.tomcat.service.deployers.WarClassLoaderDeployer">

          <property name="relativeOrder">-1</property>

          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j</property>     

       </bean>

     


    Try

     

    <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j.impl</property>

    I remember there was a bug in 5.1.0 where child package names were not taken into account by the filteredPackages attribute.

  • 11. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Nikita D Newbie

    I tried these 3 settings:

          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j.impl</property>     
          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j.impl,org.slf4j.spi</property>     
          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j,org.slf4j.impl,org.slf4j.spi</property>     
          <property name="filteredPackages">javax.servlet,org.apache.commons.logging,org.slf4j.impl,org.slf4j.spi</property>     

    Unfortunately none of them seem to have any effect.

     

    Thank you,

    Nikita

  • 12. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Nikita D Newbie

    Ivan, could you try these configurations for your app, in case there is something I'm screwing up?

     

    However, one problem with this solution even if it works, is when there are multiple apps deployed to the same server and one of them wants to use the JBoss slf4j jars, while another one has its own.

     

    Thank you,

    Nikita

  • 13. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Ivan Hrytsyuk Newbie

    Nikita,

     

    I've tried all 3 settings but without results - errors were present in logs

  • 14. Re: JBoss-5.1.0.GA Multiple SLF4J bindings
    Jason Royals Newbie

    Hi guys,

     

    Yep, its the same cause as the problem I'm having with Hibernate (http://community.jboss.org/thread/156441) on EAP 5.0.1, but also on 5.1.0.GA. I'm having the same problem now with SLF4J as well as Hibernate, all because the libs deployed to common/lib are getting in the way. I can't delete them (shared server) and I can't delete mine (because I want to use Logback, not JBoss's SLF4J implementation which goes to shared server logs). So, I'm stuck.  Looking forward to a nice solution for this, I'm yet to look at the custom deployer solution but sounds pretty awkward.

1 2 Previous Next