log4j-over-slf4j.jar和slf4j-log4j12.jar冲突...但我没有log4j-over-slf4j[英] log4j-over-slf4j.jar and slf4j-log4j12.jar conflitct... but i don't have log4j-over-slf4j

本文是小编为大家收集整理的关于log4j-over-slf4j.jar和slf4j-log4j12.jar冲突...但我没有log4j-over-slf4j的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在Maven项目中使用log4j使用SLF4J.当我在Eclipse的Tomcat和Maven上运行该项目时,一切都还好.

但是,当我将战争放在我的tomcat生产服务器中时,项目不会启动,给我这个错误.

java.lang.illegalstateException:检测到两个log4j-over-slf4j.jar 并在类路径上绑定了SLF4J-LOG4J12.JAR,抢占 Stackoverflowerror.也可以看看 http://www.slf4j.org/codes.html#log4jdelegatilegatilegatilelloop

我已经在Stackoverflow中看到了有关此错误的许多答案,我已经知道我需要排除冲突罐.问题是我的项目中没有log4j-over-SLF4J ... .war的Lib文件夹不包含此罐子,而问题仅在我的Production Server的Tomcat服务器中.我不知道该怎么办.我把我的依赖树放在这里.

[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- com.sun.faces:jsf-api:jar:2.2.13:compile
[INFO] +- com.sun.faces:jsf-impl:jar:2.2.13:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.1.0.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.1.0.Final:compile
[INFO] |  |  +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate)
[INFO] |  |  +- (org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile - omitted for duplicate)
[INFO] |  |  +- (org.javassist:javassist:jar:3.20.0-GA:compile - omitted for duplicate)
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- (org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  |  +- (com.fasterxml:classmate:jar:1.3.0:compile - omitted for conflict with 1.1.0)
[INFO] |  |  +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate)
[INFO] |  |  \- (org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile - omitted for duplicate)
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- (xml-apis:xml-apis:jar:1.0.b2:compile - omitted for conflict with 1.4.01)
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  |  \- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate)
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  +- (org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile - omitted for conflict with 3.3.0.Final)
[INFO] |  \- com.fasterxml:classmate:jar:1.1.0:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.21:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] +- log4j:apache-log4j-extras:jar:1.2.17:compile
[INFO] |  \- (log4j:log4j:jar:1.2.17:compile - omitted for duplicate)
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- org.postgresql:postgresql:jar:9.4.1208.jre7:compile
[INFO] +- org.primefaces:primefaces:jar:6.0:compile
[INFO] +- org.primefaces.themes:start:jar:1.0.10:compile
[INFO] +- commons-io:commons-io:jar:2.5:compile
[INFO] +- org.jxls:jxls-reader:jar:2.0.2:compile
[INFO] |  +- org.apache.commons:commons-digester3:jar:with-deps:3.2:compile
[INFO] |  |  +- cglib:cglib:jar:2.2.2:compile
[INFO] |  |  |  \- asm:asm:jar:3.3.1:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  |  |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |  +- org.apache.commons:commons-jexl:jar:2.1.1:compile
[INFO] |  |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.poi:poi:jar:3.12:compile
[INFO] |  |  \- (commons-codec:commons-codec:jar:1.9:compile - omitted for conflict with 1.10)
[INFO] |  +- org.apache.poi:poi-ooxml:jar:3.12:compile
[INFO] |  |  +- (org.apache.poi:poi:jar:3.12:compile - omitted for duplicate)
[INFO] |  |  \- org.apache.poi:poi-ooxml-schemas:jar:3.12:compile
[INFO] |  |     \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] |  |        \- stax:stax-api:jar:1.0.1:compile
[INFO] |  +- (org.slf4j:slf4j-api:jar:1.7.12:compile - omitted for conflict with 1.7.21)
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] |     \- (org.slf4j:slf4j-api:jar:1.7.12:compile - omitted for conflict with 1.7.21)
[INFO] +- org.jsoup:jsoup:jar:1.9.2:compile
[INFO] +- net.sourceforge.htmlunit:htmlunit:jar:2.22:compile
[INFO] |  +- xalan:xalan:jar:2.7.2:compile
[INFO] |  |  \- xalan:serializer:jar:2.7.2:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.4:compile
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.2:compile - omitted for conflict with 1.1.1)
[INFO] |  |  \- (commons-codec:commons-codec:jar:1.9:compile - omitted for duplicate)
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] |  |  \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for duplicate)
[INFO] |  +- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.22:compile
[INFO] |  +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:compile
[INFO] |  |  \- xerces:xercesImpl:jar:2.11.0:compile
[INFO] |  |     \- (xml-apis:xml-apis:jar:1.4.01:compile - omitted for conflict with 1.0.b2)
[INFO] |  +- net.sourceforge.cssparser:cssparser:jar:0.9.19:compile
[INFO] |  |  \- org.w3c.css:sac:jar:1.3:compile
[INFO] |  +- (commons-io:commons-io:jar:2.5:compile - omitted for duplicate)
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- org.eclipse.jetty.websocket:websocket-client:jar:9.2.17.v20160517:compile
[INFO] |     +- org.eclipse.jetty:jetty-util:jar:9.2.17.v20160517:compile
[INFO] |     +- org.eclipse.jetty:jetty-io:jar:9.2.17.v20160517:compile
[INFO] |     |  \- (org.eclipse.jetty:jetty-util:jar:9.2.17.v20160517:compile - omitted for duplicate)
[INFO] |     \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.17.v20160517:compile
[INFO] |        +- org.eclipse.jetty.websocket:websocket-api:jar:9.2.17.v20160517:compile
[INFO] |        +- (org.eclipse.jetty:jetty-util:jar:9.2.17.v20160517:compile - omitted for duplicate)
[INFO] |        \- (org.eclipse.jetty:jetty-io:jar:9.2.17.v20160517:compile - omitted for duplicate)
[INFO] \- xml-apis:xml-apis:jar:1.4.01:compile 

编辑:

在许多其他测试中,此问题仅在我的生产服务器Tomcat中发生,我部署在其他8个服务器中,并且系统运行正常.我想这与我的生产服务器Tomcat中运行的其他项目发生冲突.这可能吗?

推荐答案

您应该在tomcat/lib文件夹中有一个log4j-over-slf4j.jar.您检查过吗?

本文地址:https://www.itbaoku.cn/post/1574938.html

问题描述

I use SLF4J with log4j in my maven project. Everything is ok when i running the project in tomcat in eclipse, and in maven with tomcat maven plugin.

But when i put the war in my tomcat production server, the project don't start, giving me this error.

java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.

I already saw many answers in stackoverflow about this error and i already understood i need to exclude the conflict jar. The problem is i don't have log4j-over-slf4j in my project... The lib folder of the .war don't contain this jar and the problem only hapens in tomcat server of my production server. I don't know what to do. I'm putting here my dependency tree.

[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- com.sun.faces:jsf-api:jar:2.2.13:compile
[INFO] +- com.sun.faces:jsf-impl:jar:2.2.13:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.1.0.Final:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.1.0.Final:compile
[INFO] |  |  +- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate)
[INFO] |  |  +- (org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile - omitted for duplicate)
[INFO] |  |  +- (org.javassist:javassist:jar:3.20.0-GA:compile - omitted for duplicate)
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- (org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  |  +- (com.fasterxml:classmate:jar:1.3.0:compile - omitted for conflict with 1.1.0)
[INFO] |  |  +- (dom4j:dom4j:jar:1.6.1:compile - omitted for duplicate)
[INFO] |  |  \- (org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile - omitted for duplicate)
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- (xml-apis:xml-apis:jar:1.0.b2:compile - omitted for conflict with 1.4.01)
[INFO] |  +- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  |  \- (org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile - omitted for duplicate)
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] |  \- org.apache.geronimo.specs:geronimo-jta_1.1_spec:jar:1.1.1:compile
[INFO] +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  +- (org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile - omitted for conflict with 3.3.0.Final)
[INFO] |  \- com.fasterxml:classmate:jar:1.1.0:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.21:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
[INFO] +- log4j:apache-log4j-extras:jar:1.2.17:compile
[INFO] |  \- (log4j:log4j:jar:1.2.17:compile - omitted for duplicate)
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- org.postgresql:postgresql:jar:9.4.1208.jre7:compile
[INFO] +- org.primefaces:primefaces:jar:6.0:compile
[INFO] +- org.primefaces.themes:start:jar:1.0.10:compile
[INFO] +- commons-io:commons-io:jar:2.5:compile
[INFO] +- org.jxls:jxls-reader:jar:2.0.2:compile
[INFO] |  +- org.apache.commons:commons-digester3:jar:with-deps:3.2:compile
[INFO] |  |  +- cglib:cglib:jar:2.2.2:compile
[INFO] |  |  |  \- asm:asm:jar:3.3.1:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] |  |  |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for conflict with 1.2)
[INFO] |  +- org.apache.commons:commons-jexl:jar:2.1.1:compile
[INFO] |  |  \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate)
[INFO] |  +- org.apache.poi:poi:jar:3.12:compile
[INFO] |  |  \- (commons-codec:commons-codec:jar:1.9:compile - omitted for conflict with 1.10)
[INFO] |  +- org.apache.poi:poi-ooxml:jar:3.12:compile
[INFO] |  |  +- (org.apache.poi:poi:jar:3.12:compile - omitted for duplicate)
[INFO] |  |  \- org.apache.poi:poi-ooxml-schemas:jar:3.12:compile
[INFO] |  |     \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] |  |        \- stax:stax-api:jar:1.0.1:compile
[INFO] |  +- (org.slf4j:slf4j-api:jar:1.7.12:compile - omitted for conflict with 1.7.21)
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] |     \- (org.slf4j:slf4j-api:jar:1.7.12:compile - omitted for conflict with 1.7.21)
[INFO] +- org.jsoup:jsoup:jar:1.9.2:compile
[INFO] +- net.sourceforge.htmlunit:htmlunit:jar:2.22:compile
[INFO] |  +- xalan:xalan:jar:2.7.2:compile
[INFO] |  |  \- xalan:serializer:jar:2.7.2:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.4:compile
[INFO] |  |  +- (commons-logging:commons-logging:jar:1.2:compile - omitted for conflict with 1.1.1)
[INFO] |  |  \- (commons-codec:commons-codec:jar:1.9:compile - omitted for duplicate)
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] |  |  \- (org.apache.httpcomponents:httpclient:jar:4.5.2:compile - omitted for duplicate)
[INFO] |  +- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.22:compile
[INFO] |  +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:compile
[INFO] |  |  \- xerces:xercesImpl:jar:2.11.0:compile
[INFO] |  |     \- (xml-apis:xml-apis:jar:1.4.01:compile - omitted for conflict with 1.0.b2)
[INFO] |  +- net.sourceforge.cssparser:cssparser:jar:0.9.19:compile
[INFO] |  |  \- org.w3c.css:sac:jar:1.3:compile
[INFO] |  +- (commons-io:commons-io:jar:2.5:compile - omitted for duplicate)
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- org.eclipse.jetty.websocket:websocket-client:jar:9.2.17.v20160517:compile
[INFO] |     +- org.eclipse.jetty:jetty-util:jar:9.2.17.v20160517:compile
[INFO] |     +- org.eclipse.jetty:jetty-io:jar:9.2.17.v20160517:compile
[INFO] |     |  \- (org.eclipse.jetty:jetty-util:jar:9.2.17.v20160517:compile - omitted for duplicate)
[INFO] |     \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.17.v20160517:compile
[INFO] |        +- org.eclipse.jetty.websocket:websocket-api:jar:9.2.17.v20160517:compile
[INFO] |        +- (org.eclipse.jetty:jetty-util:jar:9.2.17.v20160517:compile - omitted for duplicate)
[INFO] |        \- (org.eclipse.jetty:jetty-io:jar:9.2.17.v20160517:compile - omitted for duplicate)
[INFO] \- xml-apis:xml-apis:jar:1.4.01:compile 

EDIT :

After many many many other tests, this problem only happens with my production server tomcat, i deployed in other 8 servers and the system runs ok. I suppose it's a conflict with other projects running in my production server tomcat. Can be this possible?

推荐答案

You should have a log4j-over-slf4j.jar in tomcat/lib folder. Have you checked it?