5 Replies Latest reply on Jul 15, 2009 5:05 PM by linoleum

    Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml

    rituraj_tiwari

      Folks,
      I am at my wit's end with this problem. My application has an EndUser entity fronted by an EntityHome class which is injected into the session upon successful authentication. My application has an edit profile page that lets the end user change attributes about their profile. This page makes use of AJAX: DHTML + Seam Remoting.


      The first hurdle I cleared was to make sure that the Seam Remote calls use the same conversation as the rest of the page. Otherwise, the entity manager injected into EndUserHome was appearing closed. This was done using:


      Seam.Remoting.getContext().setConversationId(#{conversation.id});
      



      With this, my AJAX calls to fetch the profile started working. The problem now is that if I try to change anything in the profile, the calls fail on the server with this:



      Caused by: java.lang.IllegalStateException: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
           at org.jboss.seam.transaction.SeSynchronizations.registerSynchronization(SeSynchronizations.java:57)
           at org.jboss.seam.transaction.UTTransaction.registerSynchronization(UTTransaction.java:92)
           at org.jboss.seam.async.AbstractDispatcher.scheduleTransactionSuccessEvent(AbstractDispatcher.java:39)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      



      I searched the web and found advise to set this in my components.xml:


      <transaction:ejb-transaction/>



      however, this leads to parse errors in my components.xml.


      If I fix the parse errors by adding xmlns:transaction="http://jboss.com/products/seam/transaction" to my components.xml, I get all kinds of errors pop up on the server as soon as the application is accessed.


      I have also tried setting the JPA RESOURCE_LOCAL transactions by setting:


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





      This shows errors similar to the ones encountered with the ejb-transaction setting:


      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:61)
           at org.jboss.seam.transaction.EntityTransaction.begin(EntityTransaction.java:81)
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:566)




      My environment is JBoss 4.2.2GA and Seam 2.0.0GA.


      Any help is greatly appreciated.


      Thanks.


      -Raj



        • 1. Re: Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
          pmuir

          Do you deploy using an EAR or a WAR?


          If an EAR, you want to use <transaciton:ejb-transaction /> otherwise, use entity transactions.

          • 2. Re: Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
            rituraj_tiwari

            Pete,


            thanks for responding. My project is an ear, where all my seam component classes live in the ejb sub-project. So, it appears I should use ejb transactions. However, when I use these, all hell breaks loose and I see repeated exceptions. I will post the stack traces shortly. In the meantime, If you have seen this before, I would appreciate if you can help me fix them.


            Thanks.


            -Raj

            • 3. Re: Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
              rituraj_tiwari

              What an ordeal! But I finally figured it out thanks to This Post.


              Bottomline, I absolutely needed <transaciton:ejb-transaction /> . Setting this was causing a boatload of repeated exceptions and redirects with this root cause:


              Caused by: javax.naming.NameNotFoundException: EjbSynchronizations not bound
                  at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                  at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                  at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                  at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                  at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
                  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
                  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
                  at javax.naming.InitialContext.lookup(Unknown Source)
                  at org.jboss.seam.Component.instantiateSessionBean(Component.java:1279)
                  at org.jboss.seam.Component.instantiate(Component.java:1265)
                  at org.jboss.seam.Component.newInstance(Component.java:1958)



              This was fixed by making sure that jboss-seam.jar was declared as an EJB module in my application.xml:


                 <module>
                    <ejb>jboss-seam.jar</ejb>
                 </module>
              


              • 4. Re: Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
                ericjung2

                I think many of us Seam users are familiar with that post :)


                In any case, this is documented in the Seam manual in section 1.2.1.10.

                • 5. Re: Data update woes: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
                  linoleum

                  Hey guys,


                  For having a background, I have a services jar which has a bunch of ejb that persist, updates, deletes, and so on. And a war which has all the pages and seam components that call the services in the jar.


                  But I have a small problem, I'm using Flamingo in the war, to call a method (with Seam Remoting) in a seam component which call a service in the jar to persist a record, but I'm having the same problem described above (Caused by: java.lang.IllegalStateException: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
                  ) Here's some of the stack trace :


                  09:55:16,331 ERROR [AMFSeamMethodInvoker] 
                  09:55:16,333 WARN  [ContextualHttpServletRequest] ended request due to exception
                  com.exadel.flamingo.service.exception.ServiceInvokationException: java.lang.reflect.InvocationTargetException
                          at com.exadel.flamingo.service.seam.util.AMFSeamMethodInvoker.makeCall(AMFSeamMethodInvoker.java:99)
                          at com.exadel.flamingo.service.seam.amf.process.AMF3RemotingMessageProcessor$AMFContextualRequest.process(AMF3RemotingMessageProcessor.java:104)
                          at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
                          at com.exadel.flamingo.service.seam.amf.process.AMF3RemotingMessageProcessor.process(AMF3RemotingMessageProcessor.java:71)
                          at com.exadel.flamingo.service.seam.amf.process.AMF3MessageProcessor.process(AMF3MessageProcessor.java:58)
                          at com.exadel.flamingo.flex.amf.process.AMF0MessageProcessor.process(AMF0MessageProcessor.java:53)
                          at com.exadel.flamingo.service.seam.AMFToSeamRequestProcessor.process(AMFToSeamRequestProcessor.java:73)
                          at com.exadel.flamingo.service.seam.AMFRemoteService.getResource(AMFRemoteService.java:79)
                          at org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80)
                          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                          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.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                          at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                          at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                          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.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
                          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
                          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
                          at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                          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.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                          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:182)
                          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(Thread.java:619)
                  Caused by: java.lang.reflect.InvocationTargetException
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                          at java.lang.reflect.Method.invoke(Method.java:597)
                          at com.exadel.flamingo.service.seam.util.AMFSeamMethodInvoker.makeCall(AMFSeamMethodInvoker.java:90)
                          ... 49 more
                  Caused by: javax.ejb.EJBException: java.lang.IllegalStateException: Transaction begin not detected, try installing transaction:ejb-transaction in components.xml
                          at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
                          at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
                          at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                  



                  In my jar components.xml I'm using the


                  <transaction:ejb-transaction/>



                  tag


                  So basically I don't if my configuration is ok or not. Please if you guys have any idea on how to solve this issue or where do I should post this issue.. I will be thanking you a lot


                  Eddie