title: Configure Infinispan in wildfly 14 standalone.xml instead of standalone-ha.xml
body: <p>I'm try to use infinispan in an application on wildfly 14 by starting using standalone.xml.
  In this case, when it is started with standalone-ha.xml/ standalone-full-ha.xml as mentioned below it works fine. </p>
  
  <blockquote>
    <p>./standalone.sh -server-config=standalone-ha.xml</p>
  </blockquote>
  
  <p>But when I try to start it using use standalone.xml I'm getting below error from infinispan while it is getting deployed.</p>
  
  <p>What is the possible reason for this and how to overcome it. (I already tried adding resource-ref / resource-env-ref to the jobss-web.xml/web.xml)</p>
  
  <p><strong>Note :</strong> </p>
  
  <p>CacheManager is injected to it's client as mentioned below</p>
  
  <pre><code>@EJB 
  CacheManager cacheManager;
  </code></pre>
  
  <p><strong>Stack Trace :</strong> </p>
  
  <pre><code>23:23:31,323 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-7) WFLYEJB0473: JNDI bindings for session bean named 'CacheManager' in deployment unit 'deployment "infinispan-invoker.war"' are as follows:
  
      java:global/application/CacheManager!infnispan.CacheManager
      java:app/application/CacheManager!infnispan.CacheManager
      java:module/CacheManager!infnispan.CacheManager
      ejb:application/CacheManager!infnispan.CacheManager
      java:global/application/CacheManager
      java:app/application/CacheManager
      java:module/CacheManager
  
  23:23:31,530 INFO  [org.jboss.weld.Version] (MSC service thread 1-7) WELD-000900: 3.0.5 (Final)
  23:23:31,755 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-3) ISPN000128: Infinispan version: Infinispan 'Estrella Galicia' 9.3.1.Final
  23:23:31,979 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 72) WFLYCLINF0002: Started client-mappings cache from ejb container
  23:23:32,155 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 3) WELD-001125: Illegal bean type javax.ws.rs.ext.MessageBodyReader&lt;java.util.Map&lt;?, ?&gt;&gt; ignored on [EnhancedAnnotatedTypeImpl] public @ApplicationScoped @Provider @Consumes class org.jboss.resteasy.plugins.providers.multipart.MapMultipartFormDataReader
  23:23:32,155 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 5) WELD-001125: Illegal bean type javax.ws.rs.ext.MessageBodyReader&lt;java.util.List&lt;?&gt;&gt; ignored on [EnhancedAnnotatedTypeImpl] public @ApplicationScoped @Provider @Consumes class org.jboss.resteasy.plugins.providers.multipart.ListMultipartReader
  23:23:32,388 INFO  [stdout] (ServerService Thread Pool -- 72) cacheContainer : server
  23:23:32,390 INFO  [stdout] (ServerService Thread Pool -- 72) cacheContainer CacheNames : []
  23:23:32,399 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 72) MSC000001: Failed to start service jboss.deployment.unit."infinispan-invoker.war".component.CacheManager.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."infinispan-invoker.war".component.CacheManager.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
      at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:57)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
      at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
      at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
      at java.lang.Thread.run(Thread.java:745)
      at org.jboss.threads.JBossThread.run(JBossThread.java:485)
  Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
      at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
      at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
      at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
      at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:127)
      at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:141)
      at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
      ... 8 more
  Caused by: javax.ejb.EJBException: org.infinispan.commons.CacheConfigurationException: ISPN000436: Cache 'default' has been requested, but no cache configuration exists with that name and no default cache has been set for this container
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:246)
      at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:388)
      at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:68)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.as.ejb3.component.singleton.StartupCountDownInterceptor.processInvocation(StartupCountDownInterceptor.java:25)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
      at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
      ... 13 more
  </code></pre>
  
  <p><strong>CacheManager.java</strong></p>
  
  <pre><code>import java.util.concurrent.TimeUnit;
  import javax.annotation.PostConstruct;
  import javax.annotation.PreDestroy;
  import javax.annotation.Resource;
  import javax.ejb.Singleton;
  import javax.ejb.Startup;
  import org.infinispan.Cache;
  import org.infinispan.manager.CacheContainer;
  
  @Singleton
  @Startup
  public class CacheManager {
  
      @Resource(lookup = "java:jboss/infinispan/container/server")
      private CacheContainer cacheContainer;
  
      private Cache&lt;String, Object&gt; cache;
  
      @PostConstruct
      public void init() {
          System.out.println("cacheContainer : " + cacheContainer);
          System.out.println("cacheContainer CacheNames : " + cacheContainer.getCacheNames());
          cache = cacheContainer.getCache("default");
      }
  
      @PreDestroy
      public void destroy() {
          cacheContainer.stop();
      }
  
      public void setCache(String key, Object value) {
          cache.put(key, value);
      }
  
      public Object getCache(String key) {
          return cache.get(key);
      }
  
      public void setCache(String key, Object value, long expiresIn, TimeUnit timeUnit) {
          cache.put(key, value, expiresIn, timeUnit);
      }
  
      public void removeCache(String key) {
          cache.remove(key);
      }
  
      public boolean hasCache(String key) {
          return cache.containsKey(key);
      }
  
  }
  </code></pre>
  
  <p><strong>standalone.xml</strong></p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:infinispan:7.0"&gt;
      &lt;cache-container name="server" default-cache="default" module="org.wildfly.clustering.server"&gt;
          &lt;local-cache name="default"&gt;
              &lt;transaction mode="BATCH"/&gt;
          &lt;/local-cache&gt;
      &lt;/cache-container&gt;
      &lt;cache-container name="web" default-cache="passivation" module="org.wildfly.clustering.web.infinispan"&gt;
          &lt;local-cache name="passivation"&gt;
              &lt;locking isolation="REPEATABLE_READ"/&gt;
              &lt;transaction mode="BATCH"/&gt;
              &lt;file-store passivation="true" purge="false"/&gt;
          &lt;/local-cache&gt;
      &lt;/cache-container&gt;
      &lt;cache-container name="ejb" aliases="sfsb" default-cache="passivation" module="org.wildfly.clustering.ejb.infinispan"&gt;
          &lt;local-cache name="passivation"&gt;
              &lt;locking isolation="REPEATABLE_READ"/&gt;
              &lt;transaction mode="BATCH"/&gt;
              &lt;file-store passivation="true" purge="false"/&gt;
          &lt;/local-cache&gt;
      &lt;/cache-container&gt;
      &lt;cache-container name="hibernate" module="org.infinispan.hibernate-cache"&gt;
          &lt;local-cache name="entity"&gt;
              &lt;transaction mode="NON_XA"/&gt;
              &lt;object-memory size="10000"/&gt;
              &lt;expiration max-idle="100000"/&gt;
          &lt;/local-cache&gt;
          &lt;local-cache name="local-query"&gt;
              &lt;object-memory size="10000"/&gt;
              &lt;expiration max-idle="100000"/&gt;
          &lt;/local-cache&gt;
          &lt;local-cache name="timestamps"/&gt;
      &lt;/cache-container&gt;
  &lt;/subsystem&gt;
  </code></pre>
  
  <p><strong>standalone-ha.xml / standalone-full-ha.xml</strong></p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:infinispan:7.0"&gt;
      &lt;cache-container name="server" aliases="singleton cluster" default-cache="default" module="org.wildfly.clustering.server"&gt;
          &lt;transport lock-timeout="60000"/&gt;
          &lt;replicated-cache name="default"&gt;
              &lt;transaction mode="BATCH"/&gt;
              &lt;file-store path="/infinispan/db" passivation="false" preload="true" purge="false"/&gt;
          &lt;/replicated-cache&gt;
      &lt;/cache-container&gt;
      &lt;cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan"&gt;
          &lt;transport lock-timeout="60000"/&gt;
          &lt;distributed-cache name="dist"&gt;
              &lt;locking isolation="REPEATABLE_READ"/&gt;
              &lt;transaction mode="BATCH"/&gt;
              &lt;file-store/&gt;
          &lt;/distributed-cache&gt;
      &lt;/cache-container&gt;
      &lt;cache-container name="ejb" aliases="sfsb" default-cache="dist" module="org.wildfly.clustering.ejb.infinispan"&gt;
          &lt;transport lock-timeout="60000"/&gt;
          &lt;distributed-cache name="dist"&gt;
              &lt;locking isolation="REPEATABLE_READ"/&gt;
              &lt;transaction mode="BATCH"/&gt;
              &lt;file-store/&gt;
          &lt;/distributed-cache&gt;
      &lt;/cache-container&gt;
      &lt;cache-container name="hibernate" module="org.infinispan.hibernate-cache"&gt;
          &lt;transport lock-timeout="60000"/&gt;
          &lt;local-cache name="local-query"&gt;
              &lt;object-memory size="10000"/&gt;
              &lt;expiration max-idle="100000"/&gt;
          &lt;/local-cache&gt;
          &lt;invalidation-cache name="entity"&gt;
              &lt;transaction mode="NON_XA"/&gt;
              &lt;object-memory size="10000"/&gt;
              &lt;expiration max-idle="100000"/&gt;
          &lt;/invalidation-cache&gt;
          &lt;replicated-cache name="timestamps"/&gt;
      &lt;/cache-container&gt;
  &lt;/subsystem&gt;
  </code></pre>