3 Replies Latest reply on Jan 4, 2012 10:34 AM by Galder Zamarreño

    Unable to run Infinispan cache in JTA

    hkapil123 Newbie

      Hello All,

      I am new to infinispan and trying to implement Cache updates in a JTA. Somehow  this doesnt seem to be working.This is not working and cache is getting updated even after calling rollback in a user transaction.

      Here are some details

      • Java (vendor and version) - JDK 1.6
      • Infinispan version - Infinispan 5.0.1
      • App server in use (if relevant) - Weblogic 11g

       

      So I create a cache Configuration and set the transactionmanagerLookup appropriately.

      1. com.xweld.services.cache.infinispan.CacheConfiguration is saved with transactionmanagerLookup set with GenericTransactionManagerLookup class ( as we are using Weblogic app server).
      2. We have a wrapper factory which gives us the required TransactionManagerLookup class. We set this class in cache Config instance. And use this instance to initialilze CacheManager later.

       

      ITransactionManagerLookup txnMgrLookup = CacheTransactionManagerLookupFactory

      .getinstance().getTransactionManagerLookup(

      ITransactionManagerLookup.TXN_MGR_GENERIC);

      cacheConfig.setTransactionMangerlookup(txnMgrLookup);


      3.  We start a Global User transaction using JNDI lookup for UserTransaction object.

        tx = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");

       

      3)      4. We call all JDBC updates on Hibernate  entities and cache update on CacheManager , created using the earlier saved CacheConfiguartion value.(step 1)

            5.  We explicitly call tx.rollback on user transaction.(no tx.commit is called)

      5)      The Hibernate  updates are reverted correctly but checking the size of cache reveals that cache size has increased and new entry has been added to cache. The updated caches don’t revert after rollback call.

      I would like to know are we supposed to set any other property to make cache updates work in JTA or if we are not using CacheConfiguration  correctly in a JTA.

       

       

      Thanks

      Hkapil