4 Replies Latest reply on May 3, 2013 10:37 PM by wolfch

    java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log

    hpgisler

      If I try to use Weld


       <dependencyManagement>
            <dependencies>
               <dependency>
                  <groupId>org.jboss.weld</groupId>
                  <artifactId>weld-core-bom</artifactId>
                  <version>1.1.4.Final</version>
                  <scope>import</scope>
                  <type>pom</type>
               </dependency>
      
               ...
               
            </dependencies>
         </dependencyManagement>
      
         <dependencies>
            <dependency>
               <groupId>org.jboss.weld.se</groupId>
               <artifactId>weld-se-core</artifactId>
               <scope>test</scope>
            </dependency>
              
            ...
      
         </dependencies>
      



      together with slf4j in a version greater than/equal to 1.6


               <dependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-log4j12</artifactId>
                  <!-- <version>1.5.11</version> -->
                  <version>1.6.2</version>
               </dependency>
            
               <dependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-api</artifactId>
                  <!-- <version>1.5.11</version> -->
                  <version>1.6.2</version>
               </dependency>
      
      



      then I get the following error:


      Caused by: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
           at org.slf4j.cal10n.LocLogger.info(LocLogger.java:122)
           at org.jboss.weld.bootstrap.WeldBootstrap.<clinit>(WeldBootstrap.java:198)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
           at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
           at java.lang.Class.newInstance0(Class.java:372)
           at java.lang.Class.newInstance(Class.java:325)
           at org.jboss.weld.environment.se.Weld.initialize(Weld.java:69)
      



      any ideas on how to solve this, if I would like to keep working with slf4j greater than 1.6?


      Thanks for any help!

        • 1. Re: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log
          ahhughes

          I obviously don't have visibility of your project configuration, but my guess is that a pre 1.6.2 slf4j dependency other than the ones you listed in your pom above is being inherited.


          Check your maven effective pom to see a complete list of dependencies, find the ones you need to modify and add them to your pom's <dependencyManagement> element. Good luck!

          • 2. Re: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log
            hpgisler

            Thank you. Thanks to your input, I've solved the problem.


            There was also a transitive dependency on slf4j-ext (1.5.10) in my test scope from some unknown package.


            After also adding slf4-ext (1.6.2) to my dependency management section, the problem went away.


            Still one (off-topic) question tough: (disclaimer: I am a maven novice)
            How would I find out the package responsible to depend on slf-ext in my test scope? (just to understand better).


            Up till now, I've (via try and error) manually excluded some of my direct dependencies and checked, whether a certain transitive dependency went away.
            But surely, this is hardly to right way to do it?

            • 3. Re: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log
              assen

              Hi,


              If you use IntelliJ IDEA the you can use Show Dependencies Graph-feature of the maven plugin to see all dependencies in your project (also the transitive) and take various actions like exclusion, change of scope etc.
              This plugin is very helpful for big projects and I love it.
              There exists also similar plugin for Eclipse.

              • 4. Re: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log
                wolfch

                mvn dependeny:tree

                 

                It will output dependency tree, even showing overrides in dependencyManagment