我在我的Maven项目中将SLF4J与log4j一起使用。当我在eclipse中的tomcat和带有tomcat maven插件的maven中运行项目时,一切正常。
但是,当我在雄猫生产服务器中发动战争时,该项目无法启动,给了我这个错误。
java.lang.IllegalStateException:在类路径上检测到log4j-over- slf4j.jar和slf4j-log4j12.jar绑定,从而抢占了StackOverflowError。有关更多详细信息,另请参见 http://www.slf4j.org/codes.html#log4jDelegationLoop。
我已经在stackoverflow中看到很多有关此错误的答案,并且我已经了解到我需要排除冲突jar。问题是我的项目中没有log4j-over-slf4j … .war的lib文件夹不包含此jar,问题仅在生产服务器的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。你检查了吗?