What is the difference between getting a transaction from the EntityManager in a session bean as opposed to useing an injected UserTransaction? I have not been anle to get the EntityTransaction to work in a session bean? Is EntityTransaction only for J2SE?
In EJB Core 16.12 (Page 448): The container must make the UserTransaction interface available to the enterprise beans that are allowed to use this interface (only session and message-driven beans with bean-managed transaction demarcation are allowed to use this interface) either through injection using the Resource annotation or in JNDI under the name java:comp/UserTransaction, in addition to through the EJBContext interface. The authenticationType and shareable elements of the Resource annotation must not be speciﬁed.
In EJB persistence spec, Page 130:
For stateful session beans with extended persistence contexts: ... � When a business method of the stateful session bean is invoked, if the stateful session beanuses container managed transaction demarcation, and the entity manager is not already associated with the current JTA transaction, the container associates the entity manager with the current JTA transaction and calls EntityManager.joinTransaction. If there is a different persistence context already associated with the JTA transaction, the container throws the EJBException. � When a business method of the stateful session bean is invoked, if the stateful session bean uses bean managed transaction demarcation and a UserTransaction is begun within the method, the container associates the persistence context with the JTA transaction and calls EntityManager.joinTransaction.