Search code examples
jakarta-eetransactionsejbjta

How CMT and BMT are managed in EJB?


How CMT and BMT are managed?

As per my understanding Container Managed Transactions are achieved with JTA which is supported by application server not webservers like tomcat.

CMT are handled by Transaction manager implementation which is specific to to each application server which internally reads the ejb-jar.xml and applies the behaviour.

BMT are demarcated with the help of user-transaction class in java api.

Is the above understanding correct?


Solution

  • Yes, it is correct. A few more transaction details:

    For CMT, the EJB container is also responsible for implementing EJBContext.setRollbackOnly and isRollbackOnly by delegating to the current transaction rolling back the transaction on exception.

    For BMT, the EJB container is also responsible for throwing an exception if a UserTransaction is not committed before method end for SLSB and singleton. For SFSB, it is responsible for suspending user transactions at method end and resuming them at the next method call.