2 Replies Latest reply on Jun 20, 2008 12:56 AM by Charles Caron

    JTA EntityManager cannot access a transactions

    Charles Caron Newbie

      Hi there,

      I need to manually start, commit (or rollback) a transaction in a javabean. For this, I inject the entityManager, and then call entityManager.getTransaction.start(). However, it always throws an exception :

      Caused by: java.lang.IllegalStateException: JTA EntityManager cannot access a transactions

      From what I read, it is caused by Seam using JPA and not JTA, but how can I force it to use JTA while being able to inject the EntityManager in my different classes ?

      Here's the line of my components.xml related to persistance :

      <persistence:entity-manager-factory name="entityManagerFactory" persistence-unit-name="dcd" />
      <persistence:managed-persistence-context name="entityManager" auto-create="true" entity-manager-factory="#{entityManagerFactory}"/>

      and my persistence.xml :

      <persistence-unit name="dcd" transaction-type="JTA">
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
               <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

      Is there a line that i need to add to my components.xml to enable JTA ?

      Note : We're not using EJB3 in this project, only POJOs and Hibernate.