Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java, Maven: SLF4J error during build

I'm working on a Java project and building it with Maven (m2e). When I do a mvn clean install I get this error first thing:

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.

First thing is that the logging seems to be fine (it's very basic). But I don't like errors in my build so I followed the URL. It says basically that the class can be found in one of several packages, so I added slf4j-simple to my dependencies. I didn't know which version to use, so I got the latest (1.7.1). The error didn't go away.

It seems that one of my dependencies (JXL) needs log4j version 1.2.14 and this is what needs slf4j. I don't think I can change this (can I?). My thought is that maybe the slf4j is the wrong version but I don't know how to figure out what version log4j needs.

So first, do I even have a problem? And second, even if I don't, is there a way to get rid of the warnings?

Here is the output of mvn dependency:tree:

[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ dpt ---
[INFO] com.nike.dpt:dpt:war:1.3-SNAPSHOT
[INFO] +- javax.servlet:jsp-api:jar:2.0:provided
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet:jstl:jar:1.2:runtime
[INFO] +- net.sourceforge.jexcelapi:jxl:jar:2.6.12:compile
[INFO] |  \- log4j:log4j:jar:1.2.14:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- org.springframework:spring-core:jar:3.1.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-asm:jar:3.1.2.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.2.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-aop:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-beans:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-aspects:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-context-support:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.1.0.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-crypto:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.1.0.RELEASE:compile
[INFO] +- com.vaadin:vaadin:jar:6.8.2:compile
[INFO] +- com.google.gwt:gwt-user:jar:2.4.0:provided
[INFO] |  +- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] |  \- javax.validation:validation-api:jar:sources:1.0.0.GA:provided
[INFO] +- org.aspectj:aspectjrt:jar:1.7.0:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.7.0:compile
[INFO] +- junit:junit:jar:4.10:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- org.mockito:mockito-all:jar:1.9.0:test
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- com.oracle:ojdbc14:jar:10.2.0.4.0:compile
[INFO] +- org.vaadin.addons:filteringtable:jar:0.5.3:compile
[INFO] +- org.vaadin.addons:popupbutton:jar:1.2.1:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.1:compile
[INFO]    \- org.slf4j:slf4j-api:jar:1.7.1:compile

I am running in the Eclipse (Juno) IDE using the Maven plugin (m2e). The CLI I am using for Maven is mvn clean package taomcat7:run or mvn clean install tomcat7:run. When I invoke Maven from a command line I do not see the slf4j error, so maybe this has to do with the m2e or Eclipse setup.

like image 226
ksnortum Avatar asked Sep 27 '12 16:09

ksnortum


2 Answers

The error message is not related to your project. It is an m2e problem and does not cause any harm. You won't see it if you build on the command-line outside Eclipse.

There is a bug about this but unfortunately they are rather willing to confuse peole than to fix it:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=387064

like image 106
unguiculus Avatar answered Oct 20 '22 19:10

unguiculus


The output of mvn dependency:tree clearly shows that both slf4j-api and slf4j-simple are on your class path. The fact that SLF4J complains about not finding org.slf4j.impl.StaticLoggerBinder means that there is another copy of slf4j-api.jar somewhere on your classpath and this is the copy being loaded into memory (rather than the copy of slf4j-api.jar in com.nike.dpt:dpt:war). Under such circumstances, because of the class loader delegation model of many application servers, the classes loaded by the server's copy of slf4j-api cannot find the classes packaged in slf4j-simple.jar located in your web-app. Typically this occurs when a copy of slf4j-api.jar is placed in the application server's lib/ folder as opposed to the WEB-INF/lib/ folder of your web-application.

What is your runtime environment? application server?

like image 1
Ceki Avatar answered Oct 20 '22 20:10

Ceki