2 Replies Latest reply on Aug 12, 2011 10:13 AM by Jens Hadlich

    Transaction management w/ Hibernate 2lc and Glassfish

    John Ament Master

      Hey there

       

      So I'm trying to configure hibernate w/ infinispan as the 2lc on a glassfish based application.  In general, everything works fine, except when I try to load an entity, modify then save it in a single method call.  I get the following in my stack trace:

       

      Caused by: org.infinispan.CacheException: java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources. 
          at org.infinispan.transaction.xa.TransactionTable.getOrCreateXaAdapter(TransactionTable.java:186)
          at org.infinispan.interceptors.TxInterceptor.enlist(TxInterceptor.java:196)
          at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:178)
          at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:132)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:57)
          at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:38)
          at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:57)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
          at org.infinispan.interceptors.BatchingInterceptor.handleDefault(BatchingInterceptor.java:76)
          at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:57)
          at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)
          at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:273)
          at org.infinispan.CacheDelegate.put(CacheDelegate.java:429)
          at org.infinispan.CacheSupport.put(CacheSupport.java:28)
          at org.hibernate.cache.infinispan.util.CacheAdapterImpl.put(CacheAdapterImpl.java:96)

       

      My configuration looks like this:

       

      persistence.xml

       

      <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.region.factory_class"
            value="org.hibernate.cache.infinispan.InfinispanRegionFactory"/>
            <property name="hibernate.cache.infinispan.cfg" value="jpa-cache.xml"/>
            <!-- If using to JPA, add to your persistence.xml -->

       

            <property name="hibernate.transaction.factory_class"
            value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.transaction.manager_lookup_class"
            value="org.hibernate.transaction.SunONETransactionManagerLookup"/>

       

      in my infinispan configuration

       

      <transaction 
            transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
            syncRollbackPhase="false"
            syncCommitPhase="false"
            useEagerLocking="false"/>
      <invocationBatching enabled="true"/>

       

      Any idea?