Infinispan : cache not found on node 2 issue
anupshandilya Nov 9, 2017 4:00 AMHi,
We have set up 2 wildfly instances in a cluster - node 1 and node 2 ( both are able to see each other )
A replicated-cache is defined on node 1. The definition is shown below.
<cache-container name="InfinispanContainer" default-cache="infinispan-cache" jndi-name="java:jboss/infinispan/Infinispan"> <transport lock-timeout="60000"/> <replicated-cache name="if-cache" mode="ASYNC"/> </cache-container>
node 2 does not have the above cache defined.
nodes are started in the order - node 1 first and node 2 second. Both form cluster.
An application is deployed on node 1 to access the above cache and write,read data from it. Code snippet is shown below ( singleton EJB)
@Singleton @Startup @ConcurrencyManagement public class InfinispanCacheManager { //@Resource(lookup="java:jboss/infinispan/Infinispan") //CacheContainer cacheContainer; public InfinispanCacheManager() { System.out.println("constructing IC manager"); } @PostConstruct public void init() { Context ctx = null; CacheContainer cacheContainer = null; try { ctx = new InitialContext(); cacheContainer = (CacheContainer)ctx.lookup("java:jboss/infinispan/Infinispan"); } catch(Exception e) { e.printStackTrace(); } if(cacheContainer != null) { System.out.println("cache is initialized "+cacheContainer.DEFAULT_CACHE_NAME); Cache<String,String> cache = cacheContainer.getCache("if-cache"); cache.put("Key","HereIsTheValueForKey"); System.out.println("value for Key "+cache.get("Key")); } else { System.out.println("cache is not initialized "+cacheContainer); } }
Now, when we restart node 1, the application tries to get deployed but fails at below line.
Cache<String,String> cache = cacheContainer.getCache("if-cache");
2017-11-08 18:52:16,444 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 72) MSC000001: Failed to start service jboss.deployment.unit."InfinispanCache-0.0.1-SNAPSHOT.jar".component.InfinispanCacheManager.START: org.jboss.msc.service.StartException in service jboss.deployment.unit."InfinispanCache-0.0.1-SNAPSHOT.jar".component.InfinispanCacheManager.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 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) at org.jboss.threads.JBossThread.run(JBossThread.java:320) 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:124) at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:138) at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54) ... 6 more Caused by: javax.ejb.EJBException: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.statetransfer.StateTransferManagerImpl.start() throws java.lang.Exception on object of type StateTransferManagerImpl at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:187) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277) at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:349) at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:68) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.as.ejb3.component.singleton.StartupCountDownInterceptor.processInvocation(StartupCountDownInterceptor.java:25) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356) at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) ... 11 more Caused by: org.infinispan.commons.CacheException: Unable to invoke method public void org.infinispan.statetransfer.StateTransferManagerImpl.start() throws java.lang.Exception on object of type StateTransferManagerImpl at org.infinispan.commons.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:172) at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:859) at org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:628) at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:617) at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:542) at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:238) at org.infinispan.cache.impl.CacheImpl.start(CacheImpl.java:849) at org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:635) at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:585) at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:451) Caused by: org.infinispan.remoting.transport.jgroups.SuspectException: Cache not running on node node 2 at org.infinispan.remoting.transport.AbstractTransport.checkResponse(AbstractTransport.java:46) at org.infinispan.remoting.transport.jgroups.JGroupsTransport.checkRsp(JGroupsTransport.java:795) at org.infinispan.remoting.transport.jgroups.JGroupsTransport.lambda$invokeRemotelyAsync$0(JGroupsTransport.java:629) at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602) at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577) at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962) at org.infinispan.remoting.transport.jgroups.SingleResponseFuture.futureDone(SingleResponseFuture.java:30) at org.jgroups.blocks.Request.checkCompletion(Request.java:152) at org.jgroups.blocks.UnicastRequest.receiveResponse(UnicastRequest.java:70) at org.jgroups.blocks.RequestCorrelator.dispatch(RequestCorrelator.java:427) at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:357) at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:245) at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:664) at org.jgroups.JChannel.up(JChannel.java:738) at org.jgroups.fork.ForkProtocolStack.up(ForkProtocolStack.java:120) at org.jgroups.stack.Protocol.up(Protocol.java:380) at org.jgroups.protocols.FORK.up(FORK.java:114) at org.jgroups.protocols.FRAG2.up(FRAG2.java:165) at org.jgroups.protocols.FlowControl.up(FlowControl.java:390) at org.jgroups.protocols.FlowControl.up(FlowControl.java:374) at org.jgroups.protocols.pbcast.GMS.up(GMS.java:1040) at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:234) at org.jgroups.protocols.UNICAST3.deliverMessage(UNICAST3.java:1070) at org.jgroups.protocols.UNICAST3.handleDataReceived(UNICAST3.java:785) at org.jgroups.protocols.UNICAST3.up(UNICAST3.java:426) at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:649) at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:155) at org.jgroups.protocols.FD_ALL.up(FD_ALL.java:200) at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:310)
It is not mandatory to run the cache on node 2 as well. Isn't it ? Can you please let me know if this is fixed.
Wildfly - wildfly-10.1.0.Final
Infinispan - infinispan-core-8.2.4.Final.jar
Thanks