博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java.lang.IllegalStateException——好头疼
阅读量:5828 次
发布时间:2019-06-18

本文共 13593 字,大约阅读时间需要 45 分钟。

       在我东,下下来一个项目总会出现启动不了的问题,这些问题往往在编译的时候发现不了,当你的服务器启动的时候,就是一片片的报错,有些问题可以通过异常的提示信息,判断出来哪里配置错了,但是也有些情况下,从异常的提示信息中压根看不出来具体哪个地方出现问题了,比如下面的这段异常信息,我就不能一下子定位到哪里错了。

八月 05, 2017 11:09:53 上午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

严重: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
八月 05, 2017 11:09:53 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@45c7519]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@520bbe8b]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
八月 05, 2017 11:09:53 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@45c7519]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@10ac1c2]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
八月 05, 2017 11:09:53 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@45c7519]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@5ec4258c]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
八月 05, 2017 11:09:53 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@45c7519]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@1f7d3aef]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
八月 05, 2017 11:09:53 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@45c7519]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@56a8310f]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
八月 05, 2017 11:09:54 上午 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stopped already. Could not load org.apache.jute.BinaryInputArchive$BinaryIndex. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.jute.BinaryInputArchive.startVector(BinaryInputArchive.java:120)
at org.apache.zookeeper.proto.GetChildrenResponse.deserialize(GetChildrenResponse.java:54)
at org.apache.zookeeper.ClientCnxn$SendThread.readResponse(ClientCnxn.java:808)
at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:89)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:291)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1041)

八月 05, 2017 11:09:54 上午 org.apache.catalina.loader.WebappClassLoader loadClass

信息: Illegal access: this web application instance has been stopped already. Could not load org.apache.logging.log4j.core.impl.ThrowableProxy. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.logging.log4j.core.impl.Log4jLogEvent.getThrownProxy(Log4jLogEvent.java:530)
at org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter.format(ExtendedThrowablePatternConverter.java:61)
at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:38)
at org.apache.logging.log4j.core.layout.PatternLayout$PatternSerializer.toSerializable(PatternLayout.java:288)
at org.apache.logging.log4j.core.layout.PatternLayout.toText(PatternLayout.java:194)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:180)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:57)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.directEncodeEvent(AbstractOutputStreamAppender.java:120)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.tryAppend(AbstractOutputStreamAppender.java:113)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:104)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:390)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:375)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:349)
at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2002)
at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1974)
at org.apache.logging.slf4j.Log4jLogger.warn(Log4jLogger.java:259)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1063)

八月 05, 2017 11:09:54 上午 org.apache.catalina.loader.WebappClassLoader loadClass

信息: Illegal access: this web application instance has been stopped already. Could not load org.apache.logging.log4j.core.impl.ThrowableProxy. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.logging.log4j.core.impl.Log4jLogEvent.getThrownProxy(Log4jLogEvent.java:530)
at org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter.format(ExtendedThrowablePatternConverter.java:61)
at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:38)
at org.apache.logging.log4j.core.layout.PatternLayout$PatternSerializer.toSerializable(PatternLayout.java:288)
at org.apache.logging.log4j.core.layout.PatternLayout.toText(PatternLayout.java:194)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:180)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:57)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.directEncodeEvent(AbstractOutputStreamAppender.java:120)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.tryAppend(AbstractOutputStreamAppender.java:113)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:104)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:390)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:375)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:349)
at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2002)
at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1974)
at org.apache.logging.slf4j.Log4jLogger.info(Log4jLogger.java:199)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Exception in thread "pool-3-thread-1" java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/impl/ThrowableProxy

at org.apache.logging.log4j.core.impl.Log4jLogEvent.getThrownProxy(Log4jLogEvent.java:530)
at org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter.format(ExtendedThrowablePatternConverter.java:61)
at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:38)
at org.apache.logging.log4j.core.layout.PatternLayout$PatternSerializer.toSerializable(PatternLayout.java:288)
at org.apache.logging.log4j.core.layout.PatternLayout.toText(PatternLayout.java:194)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:180)
at org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:57)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.directEncodeEvent(AbstractOutputStreamAppender.java:120)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.tryAppend(AbstractOutputStreamAppender.java:113)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:104)
at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:390)
at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:375)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:359)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:349)
at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2002)
at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1974)
at org.apache.logging.slf4j.Log4jLogger.info(Log4jLogger.java:199)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

我以前分析过一些异常问题,不过现在的情况是,以前的那些方法貌似都不太灵验了,因为,异常信息中没有什么和我们直接编写的代码相关的东西,这个咋弄?我看到有类没找到的问题,于是我就搜一下,如下图所示:

有啊!奇怪了,是maven依赖冲突了吗?我再搜一下看看

没有依赖冲突呀!我去,这咋弄?

编译没问题,启动tomcat服务器愣是启动不起来,那说明代码本身没问题,应该是配置的问题,但是到底哪里配置错了哪?没法子我只能重头到尾的再次检查一下各个配置文件的配置,数据库、缓存、远程接口调用、异步消息的发送、分布式配置管理等等,都查看了一遍还是没有发现问题。百度吧!从网上找了找,还是没有什么思路,后来就询问了同事M看看他遇到过类似的问题没有,不得不服,我花费了小半天没解决的问题,他一会就找到了原因。(这可能是当局者迷,旁观者清的一种情形)

我的web.xml文件中配置的日志文件是这样的,如下图所示:

但是实际上我们的项目现在使用的是log4j2,将对应的配置修改成这样就行了

最终定位到问题了——是配置文件的问题,然后我又回忆了一下为什么会出现这样的情况那?我怎么配置错了哪?配置错了我怎么一点印象都没有哪?

现在我们的环境有好多种,如下所示:

1:生产环境

2:预发布环境

3:测试环境

4:开发环境

每套环境,都有好多的配置,比如:数据库、缓存、远程接口调用、异步消息发送、分布式配置管理等等。弄错了任何一套都不好玩,常常分析问题的时候也是一件比较麻烦的事情,如果环境不同,看似相同的操作或则入参,可能会产生完全不一样的结果。

现在我是开发好了两个远程调用的接口,但是上游的测试环境不可用,只能使用预发布环境的机器联调,我们的缓存刷新的应用和接口所在的应用是不同的,所以,需要将对应的应用配置上预发布环境配置,在配置的过程中我需要比对一下原来预发布环境和本地环境有什么区别(除了一些环境配置还要别的配置文件是抽出来的),并且需要明白当初为什么这样配置,中间涉及好几个应用的配置多个配置文件的修改,在这个时间段中我不小心将配置文件的配置在比较的过程中给弄乱了。

上面这一段描述,可能仅对我自己有作用吧!

简单点讲就是,我将配置文件配置错了,所以,tomcat启动不了啦!

由于自己的不小心,犯下了这种错误,恰巧我的记忆力不好,忘记了,异常信息也提示的不明显,所以自己花了不少时间来排查!

好记性不如烂笔头,何况是烂记性哪!我想下一次,我一定能更快的定位和解决类似的问题吧!

 

转载地址:http://ggadx.baihongyu.com/

你可能感兴趣的文章
NGINX 虚拟主机使用 之三
查看>>
【Samshing专栏】动态等待符的实践指南
查看>>
Win7硬盘安装方法
查看>>
第一次亲身感受良好的ASP.NET代码积累,强壮的软件产品是【马力强劲的印钞机】万能神速企业信单据数字化系统实施经验...
查看>>
Linux基础 文件的管理 正则表达式的应用的一些比较好的 练习
查看>>
JDK安装
查看>>
Linux运维之道之网络基础学习1.4
查看>>
shell的简单编写及执行
查看>>
nginx 二级域名之一
查看>>
一分钟教你知道乐观锁和悲观锁的区别
查看>>
基础语法的练习
查看>>
RabbitMQ 集群配置
查看>>
入门一班 20181023 w vmstat top sar nload
查看>>
linex常用命令
查看>>
MySQL之SELECT
查看>>
新一代大数据技术架构
查看>>
互联网企业不能轻视的一些网络安全问题
查看>>
176条DevOps人员常用的linux命令速查表
查看>>
idou老师教你学Istio 17 : 通过HTTPS进行双向TLS传输
查看>>
C++ TCP winsock 多线程编程的代码
查看>>