我有一个通过 wildfly 部署的 heimdallr 应用程序。在这个应用程序中,我使用了由命名空间 immutant.caching 提供的缓存功能。
我第一次部署应用程序时一切正常,没有错误。如果我尝试重新部署应用程序,我会收到以下错误:
2015-05-27 18:20:54,703 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 82) MSC000001: Failed to start service jboss.infinispan.web.dist: org.jboss.msc.service.StartException in service jboss.infinispan.web.dist: java.lang.IllegalStateException: Cache container has been stopped and cannot be reused. Recreate the cache container.
at org.jboss.as.clustering.msc.AsynchronousService$1.run(AsynchronousService.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: java.lang.IllegalStateException: Cache container has been stopped and cannot be reused. Recreate the cache container.
at org.infinispan.manager.DefaultCacheManager.assertIsNotTerminated(DefaultCacheManager.java:797)
at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:389)
at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:412)
at org.jboss.as.clustering.infinispan.DefaultCacheContainer.getCache(DefaultCacheContainer.java:103)
at org.jboss.as.clustering.infinispan.DefaultCacheContainer.getCache(DefaultCacheContainer.java:94)
at org.jboss.as.clustering.infinispan.subsystem.CacheService.start(CacheService.java:78)
at org.jboss.as.clustering.msc.AsynchronousService$1.run(AsynchronousService.java:86)
... 4 more
2015-05-27 18:20:54,710 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-10) MSC000001: Failed to start service jboss.infinispan.web."my-application.war".config: org.jboss.msc.service.StartException in service jboss.infinispan.web."my-application.war".config: JBAS010291: Failed to add DIST_ASYNC my-application.war cache to non-clustered web cache container.
at org.jboss.as.clustering.infinispan.subsystem.AbstractCacheConfigurationService.start(AbstractCacheConfigurationService.java:73)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
我初始化缓存的方式是
(def site-cache (agent
(immutant.caching/cache "site-cache" :ttl [ttl :seconds])
:error-mode :continue
:error-handler (fn [the-agent exception]
(log/error "Exception in Site Agent " exception (string/join "\n" (.getStackTrace *e))))))
使用 immutant 2.x 我的理解是 immutant.caching/cache 如果容器不存在,则应该创建它。有没有办法让我验证缓存容器是否存在,如果没有在我尝试向它添加缓存之前创建它?
编辑:这是由我们的部署脚本错误引起的。已经进行了两次黑客攻击以部署相同的 .war,这导致应用程序无法正确关闭,从而导致错误。