Version 1

    I'm almost to dead because of this problem.

    I have four nodes and it is clustered with two optimistic transactional caches.

    one is for invaldaiton cache and numOwner = 1 and  and shared with jdbc cache store.

    and the other cache is replicated and just for saving data (key, name of node in where the data exist on memory).

    For that, I have to use the listener of invalidaton cache whenever the entry is added..

    (another reason that I use listener is --> Even if I put the data into first node, i'm not sure whether the data is added into first node or not. So I have to use listener)

     

    But. If i use transaction in the cache, using cache is impossible because of error like below.

    ERROR [03/20 14:25:49] o.i.i.InvocationContextInterceptor - ISPN000136: Execution error

    java.lang.IllegalStateException: Transaction DummyTransaction{xid=DummyXid{id=1}, status=3} is not in a valid state to be invoking cache operations on.

              at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:268) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.interceptors.TxInterceptor.enlistIfNeeded(TxInterceptor.java:236) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.interceptors.TxInterceptor.enlistReadAndInvokeNext(TxInterceptor.java:230) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.interceptors.TxInterceptor.visitGetKeyValueCommand(TxInterceptor.java:226) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:58) ~[infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.commands.AbstractVisitor.visitGetKeyValueCommand(AbstractVisitor.java:104) ~[infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.commands.read.GetKeyValueCommand.acceptVisitor(GetKeyValueCommand.java:58) ~[infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

              at org.infinispan.statetransfer.StateTransferInterceptor.handleTopologyAffectedCommand(StateTransferInterceptor.java:216) [infinispan-core-5.2.1.Final.jar:5.2.1.Final]

     

     

     

     

     

    Here is my source code. i made it for explanation.

     

    public class SampleTest {

     

     

              private EmbeddedCacheManager cacheManager;

              private Cache<String, String> cache;

              private Log log = LogFactory.getLog(LoggingListener.class);

     

              private static EmbeddedCacheManager createCacheManagerFromXml() throws IOException {

                        return new DefaultCacheManager("joe.xml");

              }

     

     

              @Listener

              public class MyListener {

     

     

                        @TransactionCompleted

                        public void entryTransactionCompleted(TransactionCompletedEvent<String, String> event) {

                                  log.info("MyListener2 > entryCreated with key, " + event.getCache().get("a"));

                        }

              }

     

     

              @Before

              public void setup() throws Exception {

                        cacheManager = createCacheManagerFromXml();

                        cache = cacheManager.getCache("keySetCache");

              }

     

     

              @Test

              public void must_notify_listeners_after_change_has_been_applied() {

                        cache.addListener(new MyListener());

                        cache.getAdvancedCache().addInterceptor(new CustomInterceptor(), 9);

     

                        cache.put("a", "a");

              }

    }

     

     

     

     

     

    here is my xml.

     

     

    <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

              xsi:schemaLocation="urn:infinispan:config:5.2 http://www.infinispan.org/schemas/infinispan-config-5.2.xsd"

              xmlns="urn:infinispan:config:5.2">

     

     

              <global>

                        <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport"

                                                      nodeName="AS-DG-04" clusterName="Cluster01">

                                  <properties>

                                            <property name="configurationFile" value="default/jgroups.xml" />

                                  </properties>

                        </transport>

              </global>

     

     

              <namedCache name="keySetCache">

                        <clustering mode="repl"/>

                                            <transaction

                                  transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"

                                  lockingMode="OPTIMISTIC"

                        >

                        </transaction>

              </namedCache>

    </infinispan>