4 Replies Latest reply on May 27, 2011 9:08 AM by galder.zamarreno

    Infinispan as cache in jboss as6 cluster

    venkman

      First: Sorry for the doublethread. I've created this Thread in Jboss/Clustering, but still got no answer.

       

      Perhaps, this is the right location for my problem:

       

       

      i'm trying to learn something about the new infinispan.

       

      I try to start a jboss cluster (AS 6.0.0, 2 nodes on same machine)

       

      and i try to use Infinispan as cluster cache. I want to have a cache, which switches to another node, when the working node crashes.

       

      I wrote a clustered stateful session bean like mentioned here:

       

      http://community.jboss.org/wiki/InfinispanIntegrationinAS6

       

      but how can i handle the Cache(objects)?

       

      I tried this:

       

              GlobalConfiguration gc = new GlobalConfiguration();

              gc.setTransportClass(org.infinispan.remoting.transport.jgroups.JGroupsTransport.class.getName());

              Configuration c = new Configuration();

              c.setCacheMode(Configuration.CacheMode.DIST_SYNC); //<-- here i try several enums

       

              EmbeddedCacheManager cm = new DefaultCacheManager(gc,c);

              cache = cm.getCache();

       

      in the Bean, and wrote getter and setter, but when i kill the clusternode, on which this is running, theres a switching to another node in the cluster, but the cachobject is null (I think, that's, because i set the Cache Object in the Bean --> Bean has been killed --> Object has been killed) but thats no cluster cache... .

       

      So, how can i implement a cluster cache with infinispan? Have i use xmls, annotations or coding in the bean? I read many of articles here in the Community, but none of  them helps... me.

       

      Can someone please help?

       

      PV

        • 1. Re: Infinispan as cache in jboss as6 cluster
          venkman

          After adding a "/" in the @CacheConfig ("/sfsb/default" instead of "sfsb/default"), i'm no longer getting a Nullpointer.

           

          Now i get this:

           

          Exception in thread "main" javax.ejb.NoSuchEJBException: Could not find stateful bean: 5c4oa1r-jj3tde-gmohufdb-1-gmohvfr0-dj

              at org.jboss.ejb3.cache.infinispan.InfinispanStatefulCache.get(InfinispanStatefulCache.java:402)

              at org.jboss.ejb3.cache.infinispan.InfinispanStatefulCache.get(InfinispanStatefulCache.java:391)

              at org.jboss.ejb3.stateful.StatefulCacheInterceptor.invoke(StatefulCacheInterceptor.java:55)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.concurrency.aop.interceptor.ContainerManagedConcurrencyInterceptor.invoke(ContainerManagedConcurrencyInterceptor.java:181)

              at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.stateful.StatefulInstanceAssociationInterceptor.invoke(StatefulInstanceAssociationInterceptor.java:55)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.core.context.SessionInvocationContextAdapter.proceed(SessionInvocationContextAdapter.java:95)

              at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:247)

              at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:349)

              at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:209)

              at org.jboss.ejb3.tx2.aop.CMTTxInterceptorWrapper.invoke(CMTTxInterceptorWrapper.java:52)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.remoting.ReplicantsManagerInterceptor.invoke(ReplicantsManagerInterceptor.java:56)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:182)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.stateful.StatefulContainer.dynamicInvoke(StatefulContainer.java:603)

              at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)

              at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)

              at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)

              at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:898)

              at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:791)

              at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:744)

              at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548)

              at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234)

              at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:216)

              at org.jboss.remoting.Client.invoke(Client.java:1961)

              at org.jboss.remoting.Client.invoke(Client.java:804)

              at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.remoting.ClusterChooserInterceptor.invoke(ClusterChooserInterceptor.java:84)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor.invoke(ClusteredIsLocalInterceptor.java:54)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.async.impl.interceptor.AsynchronousClientInterceptor.invoke(AsynchronousClientInterceptor.java:143)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)

              at $Proxy5.invoke(Unknown Source)

              at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:185)

              at $Proxy4.getCache(Unknown Source)

              at CacheClient.main(CacheClient.java:29)

              at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.remoting.ClusterChooserInterceptor.invoke(ClusterChooserInterceptor.java:84)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor.invoke(ClusteredIsLocalInterceptor.java:54)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.ejb3.async.impl.interceptor.AsynchronousClientInterceptor.invoke(AsynchronousClientInterceptor.java:143)

              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

              at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)

              at $Proxy5.invoke(Unknown Source)

              at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:185)

              at $Proxy4.getCache(Unknown Source)

              at CacheClient.main(CacheClient.java:29)

           

          I searched via google, but most of entries handle about SEAM, no one handles from infinispan.

           

          The TestEJB is deployed in "farm" of one node and after starting the cluster it's also available in the other nodes. So, should work, i think ... .

           

          Could anyone help?

           

          PV

          • 2. Re: Infinispan as cache in jboss as6 cluster
            venkman

            After another couple of days, i'm at this point:

             

            When i implement above mentioned code, i'm getting no exceptions anymore. But if i switch the node, my cache object is null ... So, thats no clustercache for me.

             

            Another thing, i tried is to write a bean with only the @CacheConfig(name="sfsb/sync") annotation in it. Then i use a Map for my data. That works, but that's also no real Cache for me.

             

            So, am i right, that this is no cache, or am i wrong, and that IS the functionality of infinispan... ?

             

            Please, if ANYONE knows, how to implement a bean cache in a jboss AS6.0.0 cluster with infinispan, please help me. That couldn't be so difficult for the guys here.

             

            ( My excuse for "i don't wangle it" is, that i'm a jerk, whats yours? )

             

            PV

            • 3. Infinispan as cache in jboss as6 cluster
              venkman

              So, after 13 days nobody can say, how to implements a cache in a JBoss cluster with infinispan?

               

              Now i know:

               

              - how to config various files

              - which annotations i have to use

              - which clustierung modes exists

              - ...

               

              but:

               

              not how to implement a cache object in a stateful session bean. It's still my problem, that if i generate an object, it's null when i switch to another node...

               

              Even my question about my understanding of infinispan cache wasn't been answered...

               

              PLEASE, that is no joke, no april-fools trick:

               

              I don't know how to implement a cache object in a stateful session bean in a jboss 6 cluster. Could anyone please help???

               

              PV

              • 4. Re: Infinispan as cache in jboss as6 cluster
                galder.zamarreno

                The reason no one has answered might be cos it's unclear what you're trying to do here. Are you trying to simply get your SFSBs to be cached? Or you want to create your own cache for your own use cases?

                 

                If you want to keep your own cache for your own use cases, simply follow the instructions in "Using Infinispan directly" http://community.jboss.org/docs/DOC-16180 - The problem is this thread too is that you don't seem to be following any of the suggestions in that wiki. You're simply trying to build your own clustered cache from scratch. If it does not cluster, that's likely cos the group communication layer is not finding each other.

                 

                Then you talk about a NullPointerException that you've overcome but you explain nothing about it....

                 

                All in all, it's hard to answer cos it's hard to figure out what you're trying to do