SLF4J 오류 해결
- 개발관련팁
- 2013. 8. 5.
갑자기 잘 돌아 가던 프로젝트가 아래 오류를 내면서 뻗는다.
-------------
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/chaehyun/.m2/repository/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/chaehyun/.m2/repository/org/slf4j/slf4j-simple/1.7.2/slf4j-simple-1.7.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
SLF4J: Your binding is version 1.5.5 or earlier.
SLF4J: Upgrade your binding to version 1.6.x.
---------------
뭔가 slf4j 관련 library 버전이 꼬였나 보다. 이런 젠-_-장.. 난 maven도 잘 모르는데.. 흑..
인터넷을 뒤져보니, 아래 명령어를 통해서 꼬인 버전을 찾아 보랜다.
mvn dependency:tree -Dverbose -Dincludes=org.slf4j
--------
[INFO] com.recopick.coruscant:coruscant:jar:0.1
[INFO] +- net.sf.uadetector:uadetector-resources:jar:2013.02:compile
[INFO] | +- net.sf.uadetector:uadetector-core:jar:0.9.2:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.7.2:compile - omitted for duplicate)
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.2:compile
[INFO] +- org.apache.hadoop:hadoop-client:jar:2.0.0-mr1-cdh4.3.0:provided
[INFO] | \- org.apache.hadoop:hadoop-common:jar:2.0.0-cdh4.3.0:provided
[INFO] | +- (org.slf4j:slf4j-api:jar:1.6.1:provided - omitted for conflict with 1.7.2)
[INFO] | +- (org.slf4j:slf4j-log4j12:jar:1.6.1:provided - omitted for conflict with 1.4.3)
[INFO] | \- org.apache.avro:avro:jar:1.7.4:provided
[INFO] | \- (org.slf4j:slf4j-api:jar:1.6.4:provided - omitted for conflict with 1.7.2)
[INFO] +- org.apache.hadoop:hadoop-test:jar:2.0.0-mr1-cdh4.3.0:compile
[INFO] | +- org.apache.mina:mina-core:jar:2.0.0-M5:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.5.2:compile - omitted for conflict with 1.7.2)
[INFO] | +- org.apache.ftpserver:ftpserver-core:jar:1.0.0:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.5.2:compile - omitted for conflict with 1.7.2)
[INFO] | \- org.apache.ftpserver:ftpserver-deprecated:jar:1.0.0-M2:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:1.5.2:compile - omitted for conflict with 1.7.2)
[INFO] +- org.apache.hbase:hbase:jar:0.94.6-cdh4.3.0:compile
[INFO] | +- com.yammer.metrics:metrics-core:jar:2.1.2:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.6.4:compile - omitted for conflict with 1.7.2)
[INFO] | +- org.apache.thrift:libthrift:jar:0.9.0:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.5.8:compile - omitted for conflict with 1.7.2)
[INFO] | +- (org.slf4j:slf4j-api:jar:1.4.3:compile - omitted for conflict with 1.7.2)
[INFO] | \- org.slf4j:slf4j-log4j12:jar:1.4.3:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:1.4.3:compile - omitted for conflict with 1.7.2)
[INFO] +- org.apache.mahout:mahout-core:jar:0.7-cdh4.3.0:compile
[INFO] | +- org.apache.mahout:mahout-math:jar:0.7-cdh4.3.0:compile
[INFO] | | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for conflict with 1.7.2)
[INFO] | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for conflict with 1.7.2)
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.2:compile
[INFO] | \- (org.slf4j:slf4j-api:jar:1.7.2:compile - omitted for duplicate)
[INFO] \- org.apache.oozie:oozie-client:jar:3.1.3-cdh4.0.1:compile
[INFO] \- org.apache.hadoop:hadoop-auth:jar:2.0.0-cdh4.0.1:compile
[INFO] \- (org.slf4j:slf4j-log4j12:jar:1.6.1:compile - omitted for conflict with 1.4.3)
----------------
눈을 크게 뜨고 보면, org.apache.hbase:hbase:jar 에서 문제의 1.4.3 버전을 로딩하는 것 같다. http://www.slf4j.org/codes.html 링크에 보면 친절하게 해결책이 나와 있다. 아래와 같이 pom.xml을 수정하여 특정 library에서 1.4.3을 쓰지 않도록 명시적으로 exclude를 해 주면 됨.
-----
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.94.6-cdh4.3.0</version>
<exclusions>
<exclusion>
<artifactId>maven-release-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactI>
</exclusion>
</exclusions>
</dependency>
----
eclipse를 쓰는 경우,
mvn eclipse:eclipse 를 해 준다음, eclipse를 refresh 해주면 정상동작함..
1시간 삽질했음..