4 Replies Latest reply on Apr 16, 2008 11:01 AM by ljcoomber

    JTA EntityManager cannot access a transactions

    lajoie

      Let me preface this with I'm not sure if I should post this here or in in the Seam forums.

      I have a Seam application that uses an embedded EJB3 container as it is meant to be deployed outside of JBoss AS (on Tomcat, specifically). However, there are also some background tasks that are meant to run via Quartz schedule jobs and update the database through the entity beans. Because these tasks are completely outside of Seam I'm getting the EntityManagerFactory through a JNDI lookup, however I get the following exception when I try to commit the entity beans

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


      I've tried starting, and joining the entity manager to, through by using the begin() method on the following transactions and then doing an EntityManager.joinTransaction(). I tried looking up the TransactionManager and then I tried looking up the UserTransaction and using it. In both cases I was able to retrieve the object from the JNDI tree, but got the above error. As a last resort I also tried using EntityManager.getTransaction() which of course returned nothing because the manager was not currently joined to a transaction.

      I'm sure I'm just missing something simple here but so far I haven't been able to figure it out. Any help would be really appreciated.

        • 1. Re: JTA EntityManager cannot access a transactions
          mnrz

          Hi

          could you find what is the problem on your exception? I am getting this exception as well and I've stuck at this point :(

          • 2. Re: JTA EntityManager cannot access a transactions
            mickknutson

            I am having the same issue. Any help would be great....

            • 3. Re: JTA EntityManager cannot access a transactions
              cdiggins

              Also having the same problem...

              java.lang.IllegalStateException: Could not start transaction
               at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:583)
               at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:314)
               at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:142)
               at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)
               at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
               at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
               at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
               at java.lang.Thread.run(Unknown Source)
              Caused by: java.lang.IllegalStateException: JTA EntityManager cannot access a transactions
               at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:316)
               at org.jboss.seam.persistence.EntityManagerProxy.getTransaction(EntityManagerProxy.java:110)
               at org.jboss.seam.transaction.EntityTransaction.getDelegate(EntityTransaction.java:62)
               at org.jboss.seam.transaction.EntityTransaction.begin(EntityTransaction.java:82)
               at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:578)
               ... 38 more
              


              • 4. Re: JTA EntityManager cannot access a transactions
                ljcoomber

                Have spent a while on this myself. The problem (for me at least) was that I I had enabled JTA transactions in persistence.xml, but in components.xml I had configured use of the JPA EntityTransaction API (which is for non-JTA environments) with the line:

                <transaction:entity-transaction entity-manager="#{entityManager}" />

                Removing this line fixed the problem.