1
votes
  1. I've an EJB method methodA() which is annotated with TransactionAttribute.REQUIRES_NEW.
  2. methodA() calls two EJB methods (lets say methodB(), methodC())running on a remote server (IIOP communication)
  3. methodB() performs few database inserts.. methodB is also annotated with TransactionAttribute.REQUIRED
  4. methodC() which is is also annotated with TransactionAttribute.REQUIRED and I'm making it throw some runtime exception to test transaction management.
  5. When I test my methodA for transaction management, I noticed the following ..

In OpenEJB log,

  1. TX Requires_New: No transaction to suspend.

  2. TX Requires_New : Started Transactions ... gerenimo TransactionImpl....

  3. logs from methodB execution... completes.

  4. methodC throws some RuntimeException

  5. TX Requires_New : Rolling Back transaction...

============

Even though it says Transaction is being rolled back.. the database records saved through methodA() still appears in the database. I want the database inserts should be rolled back as well.

Can you please help me understand what might be going wrong?

1

1 Answers

0
votes

The problem is that methodA, B and C are running in different Transactional Contexts, therefore, there are three different and independents transactions executing in isolation within your process.

Each appserver defines a transactional context which it's shared by the EJBs deployed in the same server.

When you make a call to an EJB running in a remote server, the current transaction is not used.

You have to implement a distributed transaction if you want to share the same transaction over different remote servers.