1 Reply Latest reply on Apr 12, 2011 10:23 AM by Mircea Markus

    Transactions in a Container Managed Bean

    Nedland Rome Newbie

      I'm using a container managed stateless bean and was wondering how I would implement transactions with infinispan. Specifically I need to get rollback working.

       

      I've created a test purposely throwing an application exception (with rollback="true") prior to the end of the method, but it still seems to commit. Looking at the examples, it shows that you need to get the transaction manager from the advanced cache. Is this a necessary step for my case?

       

      I actually can't begin and commit transactions explicitly as described in the documentation example, because my bean transactions are container managed. Is there any way of doing this?

       

      Thanks

        • 1. Transactions in a Container Managed Bean
          Mircea Markus Master

          I've created a test purposely throwing an application exception (with rollback="true") prior to the end of the method, but it still seems to commit. Looking at the examples, it shows that you need to get the transaction manager from the advanced cache. Is this a necessary step for my case?

          As long as the call to infinispan is in a transactional context AND you use the right TransactionManagerLookup for your envirpnment this should work fine.

          I actually can't begin and commit transactions explicitly as described in the documentation example, because my bean transactions are container managed. Is there any way of doing this?

          You don't need to manage them by hand. If you're confident that the method runs in a transactional context, then most likekly it's the  TransactionManagerLookup that is not properly configured.