gpt4 book ai didi

java.lang.IllegalStateException。 WebClassLoader 可能出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 08:07:29 25 4
gpt4 key购买 nike

我正在使用 Spring 开发一个 Web 应用程序,但遇到了这个奇怪的错误。我不知道它来自哪里,我一直在谷歌上努力搜索,到目前为止什么也没找到。

在我正在使用的项目中:MongoDB、Spring、WSS4J(soap 的 X.509 安全 header )、Apache CXF。我一直在试图发现是否有什么东西导致这个错误,任何特定的 Action 、行为、条件,但到目前为止我什么也没发现,有时它会在运行 3 分钟后发生,有时会在 3 小时后发生,或者根本不发生,任何线索和提示都值得赞赏。

INFO: Illegal access: this web application instance has been stopped already.  Could not load net.sf.ehcache.store.disk.Segment$1.  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:1597)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at net.sf.ehcache.store.disk.Segment$HashIterator.<init>(Segment.java:988)
at net.sf.ehcache.store.disk.Segment.hashIterator(Segment.java:936)
at net.sf.ehcache.store.disk.DiskStore$HashIterator.<init>(DiskStore.java:1038)
at net.sf.ehcache.store.disk.DiskStore$KeyIterator.<init>(DiskStore.java:1111)
at net.sf.ehcache.store.disk.DiskStore$KeyIterator.<init>(DiskStore.java:1111)
at net.sf.ehcache.store.disk.DiskStore$KeySet.iterator(DiskStore.java:949)
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskExpiryTask.run(DiskStorageFactory.java:838)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)`

最佳答案

这意味着 ehcache 线程在应用程序停止或重新部署后尝试与应用程序交互。仅当 ehcache 达到 ehcache.xml 中的限制并尝试溢出到磁盘时,才会发生这种情况。

停止应用程序时查看 tomcat 日志中的警告:

SEVERE: The web application [/APP] appears to have started a thread named [Ehcache_Worker-1] but has failed to stop it. This is very likely to create a memory leak

如果发现类似的内容,您应该在 ServletContextListener 中正确停止 ecache:

public void contextDestroyed(ServletContextEvent servletContextEvent){
CacheManager.getInstance().shutdown();
}

之后可能会 hibernate 1 秒,以确保 ehcache 停止。

http://ehcache.org/documentation/faq 中所述

If the JVM keeps running after you stop using Ehcache, you should call CacheManager.getInstance().shutdown() so that the threads are stopped and cache memory is released back to the JVM. Calling shutdown also insures that your persistent disk stores get written to disk in a consistent state and will be usable the next time they are used. If the CacheManager does not get shut down, it should not be a problem. There is a shutdown hook which calls the shutdown on JVM exit.

或者您可以在 ehcache.xml 中设置属性 overflowToDisk="false" 或在每次部署应用程序时重新启动 tomcat。

关于java.lang.IllegalStateException。 WebClassLoader 可能出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11842927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com