I have a following code structure, I need guidence on how to start a local transaction cascaded from a NOT_SUPPORTED transaction type method in same EJB.

@Stateless
@TransactionManagement(value = TransactionManagementType.CONTAINER)
public class SessionBean implements SessionBeanInterface{
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public void methodA() {
        methodB();
    }

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void methodB() {

    }

}

Currently when I try this i get below exception.

No active transaction for PuId=App#EJB.jar#Persistence

1

There are 1 answers

2
Amit On BEST ANSWER

The way you have called "methodB" would not give a chance to the EJB Container to start a transactional context for you. To do that you have to invoke that method through either Remote or Local views/interface.

It is the container who supplies you these additional features and hence it is necessary to route your calls through interface than. (On a side note this is Proxy Design Pattern).

If you directly call "methodB" as you have done in above code snippet, it is just another method call without container intervention.