I have a heimdallr application that is deployed via wildfly. In this application I am using the cache functionality that is provided by the namespace immutant.caching.
The first time I deploy the application everything goes fine without error. If I attempt to redeploy the application I get the following error:
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]
The way I initialize the cache is
(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))))))
With using immutant 2.x my understanding is that the immutant.caching/cache should create the container if it doesn't exist. Is there a way for me to verify the cache container exists, and if not create it before I attempt to add a cache to it?
EDIT: This was being caused by an error with our deployment scripts. A hack had been done to deploy the same .war twice, which caused the application to not shut down properly causing the error.
This was being caused by an error with our deployment scripts. A hack had been done to deploy the same .war twice for an application requirement. The hack stopped the application from shutting down cleanly when a redeployment happened, and was causing the issue with the cache.