1 Reply Latest reply on Jul 13, 2010 6:44 AM by David Salter

    Error with Weld Logger

    David Salter Novice

      Hi,


      I'm attempting to inject a Weld logger into my app running on JBoss 6.0M3 and getting a problem.


      I've defined the injection as:


      @Inject     org.slf4j.Logger log;



      And added the following to my pom.xml


           <dependency>
                <groupId>org.jboss.weld</groupId>
                <artifactId>weld-logger</artifactId>
                <version>1.0.0-CR2</version>
           </dependency>



      When I deploy to JBoss however, I get the following stack trace.


      ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Instantiated: name=vfs:///D:/DevTools/JBoss6.0.0.M3/server/default/deploy/test.war_WeldBootstrap
      state=Described: java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
              at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:277) [:1.5.6]
              at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:245) [:1.5.6]
              at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:258) [:1.5.6]
              at org.jboss.weld.util.serviceProvider.DefaultServiceLoader.<clinit>(DefaultServiceLoader.java:58)
              at org.jboss.weld.logging.MessageConveyorFactory.load(MessageConveyorFactory.java:32)
              at org.jboss.weld.logging.MessageConveyorFactory.messageConveyerFactory(MessageConveyorFactory.java:50)


      Any ideas how to fix this?


      Cheers.

        • 1. Re: Error with Weld Logger
          David Salter Novice

          Ah, it looks like SL4J provided with Weld Logging is different to the one provided by JBoss 6.


          I've fixed the problem by excluding SL4J from the Weld logging dependency in Maven.



          <dependency>
               <groupId>org.jboss.weld</groupId>
               <artifactId>weld-logger</artifactId>
               <version>1.0.0-CR2</version>
               <exclusions>
                    <exclusion>
                         <groupId>org.slf4j</groupId>
                         <artifactId>slf4j-api</artifactId>
                    </exclusion>
               </exclusions>
          </dependency>