解决方法:
重新部署时关掉游览器中正在访问项目的页面,或者重启服务器都可以解决该问题。
问题分析:
当热部署Web应用程序时,可能因IDE进行热部署或者重新部署项目时,因之前在游览器中创建的线程仍在运行。但重新部署后他们的类加载器/上下文是无效的,并且由于它的原始web应用程序(以前的运行时环境)已被重新部署,因此面临非法访问异常/非法状态异常。
因此,正如此处所述,重新启动并不能永久解决此问题。所以最好实现线程池的托管。
今天在做毕业设计时因为修改了一点业务代码,所有重新部署了下项目,然后就报了个错。详细错误信息如下:
org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading 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. java.lang.IllegalStateException: 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. at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1355) at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1025) at com.mysql.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:90) at com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:63) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at java.base/java.lang.Thread.run(Thread.java:832)
关键信息如下:
this web application instance has been stopped already. Could not load [].
项目环境:
IDE:IDEA 2021.3.1
服务器:Tomcat8.0.50
游览器:Microsoft Edge Bate