现象:[2023-06-01 15:38:56 293] [INFO] [http-nio2-9060-exec-7] [core] [Illegal access: this web application instance has been stopped already. Could not load [org.jboss.resteasy.plugins.providers.jaxb.json.JettisonXmlSeeAlsoProvider]. 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 [org.jboss.resteasy.plugins.providers.jaxb.json.JettisonXmlSeeAlsoProvider]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
原因
应用卸载不干净,老应用未停止线程加载类,同时会导致不能卸载class,反复加载class导致元数据区不足报OutOfMemoryError:Metaspace。
解决方案
临时解决方案:
在修改不了应用的前提下,只要重部署了应用,就需要重启TongWeb释放无用的线程和Metaspace区内存,否则多次重部署后还会报该异常。
增大元空间最小和最大值,只能缓解 OutOfMemoryError:Metaspace 出现的频率。
-XX:MetaspaceSize=2048m
-XX:MaxMetaspaceSize=2048m
终极解决方案:
TongWeb的重部署reload实际操作就是对应用重新stop又start了一下,而这个过程除了class的重新加载以外,对于web.xml中定义的一些资源,如listener,filter,servlet等也重新stop又start了。
所以这时需要在listener或servlet的destory中停止应用启动的端口或线程,这样应用服务器在stop应用时,会调用listener或servlet的destory方法,从而可以销毁应用创建的资源。
另外,以上适用于应用部署时启动的端口,重部署提示端口被占用问题;
1万+

被折叠的 条评论
为什么被折叠?



