8
votes

Im am new to maven and the last two days i try to integrate maven into a small web project. (I use Eclipse Juno as IDE). First I generated a new project (structure) with the "mvn-archetype-webapp" command and copied the sources from the project into this structure. Then I added all dependencies to the pom.xml so that I could compile and start the project with the tomcat7 plugin. So far everything works fine except the SLF4J Error Messages at the start of every maven command:

    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
    SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J:
    See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

My pom.xml dependencies looks like this:

    <!-- properties -->
    <properties>
        <spring.version>3.1.1.RELEASE</spring.version>
    </properties>

    <!-- dependencies -->   
    <dependencies>

        <!-- logging -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.0.6</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.6.6</version>
            <scope>runtime</scope>
        </dependency>

        <!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <!-- Spring 3 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>   
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>                       
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>               
        </dependency>

        <!-- jee -->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- tiles -->
        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-core</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-api</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tiles</groupId>
            <artifactId>tiles-jsp</artifactId>
            <version>2.2.2</version>
        </dependency>

        <!-- jstl -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

Can somebody help me with this issue?

7

7 Answers

8
votes

Eclipse Juno and Indigo, when using the bundled maven version(m2e), are not suppressing the message SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". This behaviour is present from the m2e version 1.1.0.20120530-0009 and onwards.

Although, this is indicated as an error your logs will be saved normally. The highlighted error will still be present until there is a fix of this bug. More about this in the m2e support site.

The current available solution is to use an external maven version rather than the bundled version of Eclipse. You can find about this solution and more details regarding this bug in the question below which is the exact same problem you are facing.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error

3
votes

This error comes from eclipse running maven, not from your project, so it should not affect your build process or the resulting files.

I assume this is a problem relating to maven using not slf4j or another logging tool, but eclipse or a maven plugin tries to.

The easiest way to get rid of the error is use an external maven instead of the runtime in eclipse you can configure this in Preferences -> Maven -> Installations.

3
votes

I'm experiencing the same issue: I've copied my POM to an empty project, and have whittled it down to nearly nothing (see below) -- and am still seeing the error. I can validate that it doesn't go away by adding SLF4J bindings (logback, etc) to the POM -- the message is apparently coming from Maven itself, not the project software being compiled and tests. (I'm now getting it from a completely empty project.)

The best thing I can figure out is that I think it has something to do with Eclipse: when I run Maven manually, from the command line, the error does not appear -- only when invoking under Eclipse. (I'm using Eclipse Helios Release 2 on MacOSX, just FYI, so we know the problem isn't limited to your version, Juno.)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>testing</groupId>
  <artifactId>testing</artifactId>
  <version>0.0.1-SNAPSHOT</version>

</project>

FYI, in response to Ceki's suggestion, here's the results of maven's dependency tree goal:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building testing 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ testing ---
[INFO] testing:testing:jar:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.496s
[INFO] Finished at: Thu Oct 04 10:05:41 MDT 2012
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------

Not too informative, but there it is.

1
votes

The dependency declarations look good. Logback and slf4j will be shipping in your web-app. However, I suspect that slf4j-api.jar is somehow included in Tomcat (but not logback).

BTW, the The mvn dependency:tree command is your friend. What does it say?

0
votes

Try adding the dependency for logback-core.

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.0.6</version>
        <scope>runtime</scope>
    </dependency>
0
votes

"with the tomcat7 plugin"

The tomcat7 plugin has the SLF4J dependency. I had the same problem until I assigned the dependency directly to the tomcat7 plugin.

<pluginManagement>
<plugins>
   <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <dependencies>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.7.5</version>
            </dependency>                    
        </dependencies>
        <configuration>
            <!-- ...snip... -->
        </configuration>
    </plugin>
</plugins>
</pluginManagement>
-1
votes

You can add this to your pom properties.

    <org.slf4j-version>1.7.5</org.slf4j-version>