Tomcat运行时异常: Illegal access: this web application instance has been stopped already

Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

一般有Illegal access: this web application instance has been stopped already.  Could not load+....+The eventual following stack trace is caused by+.......这种类型的错误都是因为重新加载失败引起的;

原因:

tomcat重新装载web应用程序失败导致的。当应用程序卸载时,并不会关闭所有的线程。当tomcat已经关闭了其类加载器后,一些线程依然会继续运行,这样就导致出错。不过这个异常不影响正常使用,但不管影响不影响,总在那出现不好。

在tomcat重启的时候,因为之前的tomcat中的线程还没有完全关闭,新启动tomcat就会报这个异常,不过这个不影响正常使用,只是跳个异常挺烦人的。使用过hibernate, spring或其他大型组件,当一个WEB应用系统中有很多类时,如果开启了Tomcat的reloadable=true,那么每当相关文件改变时, Tomcat会停止web app并释放内存,然后重新加载web app.这实在是个浩大的工程。所以我们总是在想如果能有只重载某几个类的功能,将极大的满足了我们的调试。

解决办法:

方法1:修改tomcat目录下的context.xml, 找到<Context>标签,把reloadble的属性值设为:reloadable="false",即<Context reloadable="false">。

方法2:将tomcat的 server.xml 中的Context的reloadable设成false。比如:<Context path="/expert" docBase="expert" debug="0" reloadable="false">

如果在server.xml中没有找到context的配置信息,可以直接把“<Context path="/expert" docBase="expert" debug="0" reloadable="false"></Context>”加在<Server>标签内部,至今没有出现问题。
 

发布了162 篇原创文章 · 获赞 30 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/ScorpC/article/details/99688741