2012-08-07 36 views
1

我正在开发一个Web应用程序与春天,我有这个奇怪的错误。我无法弄清楚它来自哪里,我一直在努力地搜索,到目前为止还没有发现任何东西。java.lang.IllegalStateException。与WebClassLoader可能的错误

在我正在使用的项目中:MongoDB,Spring,WSS4J(SOAP的X.509安全头文件),Apache CXF。我一直在试图发现是否有什么导致这个错误,任何特定的行为,行为,条件的东西,但我到目前为止没有发现任何东西,有时它发生在跑步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)` 

回答

1

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

看看Tomcat的日志的警告时停止你的应用程序:

重度:Web应用程序[/ APP]似乎已经开始了一个名为[Ehcache_Worker-1]螺纹 但未能阻止它。 这很可能造成内存泄露

如果发现这样的事情,你应该正确停止ecache在你的ServletContextListener:后

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

也许有1秒的睡眠,可以肯定的Ehcache停止。

正如http://ehcache.org/documentation/faq

如果JVM继续运行你停止使用的Ehcache后提到的,你应该叫 CacheManager.getInstance()。shutdown()方法,使线程停止 和高速缓存内存被释放回到JVM。调用关机还 可确保持久磁盘存储以 一致状态写入磁盘,并且在下次使用它们时可用。如果 CacheManager不关闭,它应该不成问题。 有一个关闭钩子,它调用JVM退出时的关闭。

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