码迷,mamicode.com
首页 > 编程语言 > 详细

Java学习-051-Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError

时间:2017-11-09 00:48:16      阅读:453      评论:0      收藏:0      [点我收藏+]

标签:...   依赖关系   erb   dep   rtu   ogg   xpl   exec   加载   

错误信息:Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError

场景:

产品服务器采用spring-boot框架开发,zookeeper作为微服务框架,打包完成后发现服务无法启动,tomcat启动错误日志显示如下所示:

技术分享

日志文本详情:

 1 08-Nov-2017 11:32:10.984 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
 2 SLF4J: Class path contains multiple SLF4J bindings.
 3 SLF4J: Found binding in [jar:file:/shenmajr/shenma-frss-web/webapps/ROOT/WEB-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
 4 SLF4J: Found binding in [jar:file:/shenmajr/shenma-frss-web/webapps/ROOT/WEB-INF/lib/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
 5 SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
 6 SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. 
 7 SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
 8 08-Nov-2017 11:32:11.129 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 9  org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
10     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
11     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
12     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
13     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
14     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
15     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
16     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
17     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
18     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
19     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
20     at java.lang.Thread.run(Thread.java:745)
21 Caused by: java.lang.ExceptionInInitializerError
22     at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72)
23     at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
24     at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
25     at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
26     at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
27     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
28     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
29     at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
30     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273)
31     at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:85)
32     at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
33     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5292)
34     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
35     ... 10 more
36 Caused by: 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.
37     at org.slf4j.impl.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:54)
38     ... 23 more

 

解决方法如下所示:

类库冲突是因为tomcat在启动加载类库时,加载类引起的。通过mvn dependency:tree命令查看maven项目工程类库的依赖关系,可以发现如下均有引用slf4j-log4j12的类库,因而在项目工程中将此引用依赖通过exclusions取消即可。

技术分享

(o)…,上图中红框错位了,大家勿怪哈

 技术分享

实际项目中,可能存在各种各样的冲突,但只要稍用心排查一下冲突的依赖,解决此类问题还是比较容易的。

 

Java学习-051-Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError

标签:...   依赖关系   erb   dep   rtu   ogg   xpl   exec   加载   

原文地址:http://www.cnblogs.com/fengpingfan/p/7807036.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!