While testing a ported J2EE application with OC4J, I encountered a problem with the combination of the RequiresNew and Mandatory transaction attributes.
Deeper investigation showed that the application has a call chain setSessionContext() - init() - SessionBeanFacade.create() - EntityBean transactional method.
With a little help of the OC4J Development folks, we found that reading the EJB specification is valuable. It clearly states that setSessionContext() is not in a transaction state and it's up to the container vendor how this is implemented.
The specification clearly states that the bean developer should not rely on a containers behaviour and program conservatively.
In essence: Never call a transactional bean method from within setSessionContext().
References:
- EJB 2.0, chapters 7.5.7, 7.6.1, 7.8.2, 17.6.5
- EJB 2.1, chapters 7.5.9, 7.6.1, 7.8.2, 17.6.5