Announcement Announcement Module
No announcement yet.
JTA Transaction Behavior between the container and Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JTA Transaction Behavior between the container and Spring

    I'm running within GlassFish 3.0.1 and I have an EJB that is also a WebService. The class is annotated to allow for a Container transaction to begin on method invocation.

    My EJB calls into several Spring Dao class that are using the JPATemplate. The EntityManagerFactory is being injected into my Dao classes with the following annotation:
        public void setEntityManager(EntityManagerFactory entityManagerFactory) {
            jpaTemplate = new JpaTemplate(entityManagerFactory);
    and configuration:
        <jee:jndi-lookup id="entityManagerFactory" jndi-name="persistence/my-pu"/>
    And my persistence.xml is as follows:
      <persistence-unit name="my-pu" transaction-type="JTA">
    I can see the Transaction being started by the container before method invocation on my EJB and I can see Spring recognizing that there is an existing transaction when it acquires a transaction on method invocation of my dao classes. The problem is that it appears that work in my EntityManager is not transacted. When I read an object from the EntityManager, based upon an ID, a second read will return a different instance of the object. While the data is the same within the instances the objects are not the same.

    When an exception is thrown as a result of an insert operation I can see the transaction marked for rollback and it is rolled back, but the data is not. All inserts that occurred prior to the exception are committed.

    Can the JTATransactionManager participate in a running container managed transaction that is begun on an EJB method invocation?