tomcat-通过添加日志文件,排查启动错误

问题

启动报错

java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:589)
    at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:397)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
    at java.lang.Thread.run(Unknown Source)

这个不是真正的错误,真正的错误是其他错误。因为日志不全,所以看不到,解决方法?添加日志文件。具体方法:
https://juejin.im/post/686596...


真正的错误

INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 10, 2020 3:00:20 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class kalvan.log.logback.web.LogbackConfigListener
java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext //转换异常
 at kalvan.log.logback.web.LogbackConfigListener.contextInitialized(LogbackConfigListener.java:103)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
 at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
 at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
Sep 10, 2020 3:00:20 PM org.apache.catalina.core.ApplicationContext log



SLF4J: Class path contains multiple SLF4J bindings. //这里才是真正的错误原因,即同一个类,有多个jar包含
SLF4J: Found binding in [jar:file:/Users/gongzhihao/IdeaProjects-ys/qrcode/qrcode-server-pool/target/qrcode-server-pool-1.0.0-SNAPSHOT/WEB-INF/lib/activemq-all-5.8.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] //排除这个jar
SLF4J: Found binding in [jar:file:/Users/gongzhihao/IdeaProjects-ys/qrcode/qrcode-server-pool/target/qrcode-server-pool-1.0.0-SNAPSHOT/WEB-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] //只保留这个jar
SLF4J: Found binding in [jar:file:/Users/gongzhihao/IdeaProjects-ys/qrcode/qrcode-server-pool/target/qrcode-server-pool-1.0.0-SNAPSHOT/WEB-INF/lib/slf4j-jdk14-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] //排除这个jar
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.


SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] //有3个,最终用这个

解决方法:排除其他的,只留下一个。

怎么知道要排除哪一个jar?

比较正常的项目和异常的项目

正常项目
tomcat-通过添加日志文件,排查启动错误_第1张图片

异常项目 //多了一个jdk14的日志jar,多的jar刚好可以和报错信息匹配
tomcat-通过添加日志文件,排查启动错误_第2张图片

解决方法

排除jar


        
          slf4j-jdk14
          paylib.log
        
        
          activemq-all
          paylib.mq.activemq
        
        
          activemq-pool
          paylib.mq.activemq
        
      

你可能感兴趣的:(tomcat)