I am writing an EJB with BMP. I would like to know if I have to call any method in the UserTransaction object (that is used in the EJB) in the ejbPassivate/Activate methods as we have to release all the resources.
I am not very sure if UserTransaction is a resource.
If you want to write beanmanaged transaction then you have to call methods on UserTransaction object.
I have used the begin, commit, rollback methods of the transaction.
In ejbactivate/passivate methods we have to release system resources like connections, files etcs and get back the resources when activated.
Should I release & restore UserTransaction also in ejbactivate/passivate?
You can only use BMT with session beans, not entity beans.
ejbActivate and ejbPassivate are not called by the container on stateless beans, only with stateful beans.
You should definitely avoid doing TX control stuff in the ejbActivate and ejbPassivate methods. That is poor design!