immutant无法将缓存添加到Web缓存容器

时间:2015-05-27 20:41:34

标签: caching clojure wildfly immutant

我有一个通过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))))))

使用immantant 2.x我的理解是immutant.caching / cache应该创建容器,如果它不存在的话。有没有办法让我验证缓存容器是否存在,如果在我尝试向其添加缓存之前没有创建它?

编辑:这是由我们的部署脚本出错引起的。已经完成了两次黑客攻击,这导致应用程序无法正常关闭导致错误。

2 个答案:

答案 0 :(得分:2)

听起来您可能没有使用lein-immutant插件来创建war文件。该插件为war文件添加了一些元数据,以确保类路径正确等等。绝对有可能通过其他方式创建战争文件,例如lein-ring插件可以在第一次成功部署,并在取消部署时让应用服务器处于不可预测的状态。

答案 1 :(得分:0)

这是由我们的部署脚本出错引起的。为完成应用程序要求,已经完成了两次同样的.war部署。当重新部署发生时,hack阻止应用程序干净地关闭,并导致缓存问题。