10 Replies Latest reply on Jun 13, 2008 12:56 PM by christophea

    need to understand transaction:ejb-transaction

      according to the seam reference I use <transaction:ejb-transaction/> in my components.xml (I use JBoss 4.2).


      When I use this, then I get the following exception when I try to access the database after the INVOKE_APPLICATION phase:


      12:10:18,547 ERROR [SynchronizationRegistry] Exception processing transaction Synchronization after completion
      ....
      Caused by: javax.transaction.NotSupportedException
      



      It seems to me that the 2 transactions per request stuff is not working anylonger if I install the EJB synchronization component.


      Any ideas?

        • 1. Re: need to understand transaction:ejb-transaction
          pmuir

          Many examples use this e.g. the booking example.


          As ever, it's hard to help unless you post the whole stack trace.

          • 2. Re: need to understand transaction:ejb-transaction

            I just didn't want to bother you with all the details :)


            here is my usecase:


            I am using an eventscoped entity home object. Its Id is set via a page parameter.


            this entity has a list of sub-entities which I use in a datatable that has a rich:datascroller attached.
            the datascroller is bound another event-scoped seam bean (RichDataScrollerHelper), which has a method that observes the afterTransactionSuccess event and it may change the page of the datascroller.


            the setPage method of the datascroller-component must access the datamodel (and thus the enityhome bean).


            I am not sure why this exception is happening when I use ejb-transaction syncronization.


            I guess it's like this:
            when I call the remove-function of the entity-home, the EBJ container starts a transaction. then I remove the entity and the afterTransactionSuccess is queued. now the EJB container commits this transaction.
            After that seam processes the events.
            I see that the exception happens after INVOKE_APPLICATION phase, but before RENDER_RESPONSE phase.


            Now my obserer method on RichDataScrollerHelper is called and tries to access the database again. But this seems not to be allowed when using ejb-transaction.


            here's the complete stack trace:


            14:01:22,538 INFO  [STDOUT] Hibernate: 
                delete 
                from
                    ImageThumbnail 
                where
                    id=? 
                    and version=?
            14:01:22,553 INFO  [DebugObserver] JSF phase: after  INVOKE_APPLICATION 5
            14:01:22,584 ERROR [SynchronizationRegistry] Exception processing transaction Synchronization after completion
            javax.faces.FacesException: javax.el.ELException: /private/users/gallery/user_galleries.xhtml @36,85 value="#{webUserGalleriesHome.instance.
            webUser_Galleries}": Error reading 'instance' on type com.twentyfouract.web.session.WebUserGalleriesHome_$$_javassist_11
                 at javax.faces.component.UIData.getValue(UIData.java:585)
                 at org.ajax4jsf.component.UIDataAdaptor.getValue(UIDataAdaptor.java:1459)
                 at org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:70)
                 at org.ajax4jsf.component.SequenceDataAdaptor.createDataModel(SequenceDataAdaptor.java:64)
                 at org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:592)
                 at org.ajax4jsf.component.UIDataAdaptor.getRowCount(UIDataAdaptor.java:233)
                 at org.richfaces.component.UIDatascroller.getRowCount(UIDatascroller.java:365)
                 at org.richfaces.component.UIDatascroller.getPageCount(UIDatascroller.java:344)
                 at org.richfaces.component.UIDatascroller.getPageCount(UIDatascroller.java:361)
                 at com.twentyfouract.web.ui.RichDataScrollerHelper.checkPages(RichDataScrollerHelper.java:43)
                 at com.twentyfouract.web.ui.RichDataScrollerHelper.checkPages(RichDataScrollerHelper.java:56)
                 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 org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                 at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
                 at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
                 at org.jboss.seam.core.Events.raiseEvent(Events.java:84)
                 at org.jboss.seam.async.AsynchronousEvent.call(AsynchronousEvent.java:27)
                 at org.jboss.seam.async.Asynchronous.executeInContexts(Asynchronous.java:76)
                 at org.jboss.seam.async.Asynchronous.execute(Asynchronous.java:45)
                 at org.jboss.seam.async.TransactionSuccessEvent.afterCompletion(TransactionSuccessEvent.java:24)
                 at org.jboss.seam.transaction.SynchronizationRegistry.afterTransactionCompletion(SynchronizationRegistry.java:42)
                 at org.jboss.seam.transaction.EjbSynchronizations.afterCompletion(EjbSynchronizations.java:80)
                 at org.jboss.ejb3.stateful.SessionSynchronizationInterceptor$SFSBSessionSynchronization.afterCompletion(SessionSynchronizationInterceptor.j
            ava:87)
                 at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:136)
                 at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:342)
                 at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:95)
                 at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1256)
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
                 at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
                 at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
                 at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
                 at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:592)
                 at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:330)
                 at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:231)
                 at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:182)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                 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.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$FilterChainImpl.doFilter(SeamFilter.java:73)
                 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                 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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                 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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                 at java.lang.Thread.run(Thread.java:619)
            Caused by: javax.el.ELException: /private/users/gallery/user_galleries.xhtml @36,85 value="#{webUserGalleriesHome.instance.webUser_Galleries
            }": Error reading 'instance' on type com.twentyfouract.web.session.WebUserGalleriesHome_$$_javassist_11
                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
                 at javax.faces.component.UIData.getValue(UIData.java:582)
                 ... 79 more
            Caused by: javax.transaction.NotSupportedException
                 at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:79)
                 at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.begin(BaseTransactionManagerDelegate.java:77)
                 at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.begin(ServerVMClientUserTransaction.java:124)
                 at org.jboss.seam.transaction.UTTransaction.begin(UTTransaction.java:39)
                 at org.jboss.seam.util.Work.workInTransaction(Work.java:35)
                 at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                 at com.twentyfouract.web.session.WebUserGalleriesHome_$$_javassist_11.getInstance(WebUserGalleriesHome_$$_javassist_11.java)
                 at sun.reflect.GeneratedMethodAccessor278.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
                 at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                 at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                 at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
                 at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                 at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                 ... 80 more
            14:01:22,600 INFO  [DebugObserver] JSF phase: before RENDER_RESPONSE 6
            14:01:22,615 INFO  [STDOUT] Hibernate: 
                select



            hmm... the select in the RENDER_RESPONSE phase works fine...





            • 3. Re: need to understand transaction:ejb-transaction
              pmuir

              Yes, I guess this falls into the gap between the two transactions.


              Can we see the component which includes the @Observer (including any class level/method level annotations)?

              • 4. Re: need to understand transaction:ejb-transaction

                sure, here are the relevant code parts:


                @Name("richDataScrollerHelper")
                @BypassInterceptors
                public class RichDataScrollerHelper{
                
                     UIDatascroller dataScroller2;
                
                     public UIDatascroller getDataScroller2() {
                         return dataScroller2;
                    }
                
                     public void setDataScroller2(UIDatascroller dataScroller2) {
                         this.dataScroller2 = dataScroller2;
                    }
                
                     public void checkPages(UIDatascroller ds) {
                          if (ds == null) {
                               return;
                          }
                          int pageCount = ds.getPageCount();
                          int pageIndex = ds.getPageIndex();
                          if (pageIndex > pageCount) {
                               ds.setPage(UIDatascroller.LAST_FACET_NAME);
                          }
                     }
                     
                     /**
                      * if the current page is greater than the maximum pages we have,
                      * we go to the last page
                      */
                     @Observer("org.jboss.seam.afterTransactionSuccess")
                     public void checkPages() {
                          checkPages(dataScroller);
                     }
                     
                }
                



                here is the JSF binding of the datascroller:


                <rich:dataGrid id="gallery_datagrid" value="#{galleryHome.instance.imageMetaInfos}" 
                                  var="gallery_imageMetaInfo" columns="2" elements="4">
                     <f:facet name="header">
                         <rich:datascroller renderIfSinglePage="false" binding="#{richDataScrollerHelper.dataScroller2}"/>
                    </f:facet>
                
                

                • 5. Re: need to understand transaction:ejb-transaction
                  pmuir

                  Try adding @Transactional - then Seam can begin a transaction if necessary.

                  • 6. Re: need to understand transaction:ejb-transaction

                    still the same exception..


                         @Observer("org.jboss.seam.afterTransactionSuccess")
                         @Transactional
                         public void checkPages() {
                              checkPages(dataScroller2);
                         }
                    

                    • 7. Re: need to understand transaction:ejb-transaction

                      any other ideas, or should I raise a jira for this?

                      • 8. Re: need to understand transaction:ejb-transaction
                        christophea

                        Any news on that ?


                        I am experiencing the same exception:



                        javax.transaction.NotSupportedException

                        with similar situation :



                        @Observer("org.jboss.seam.afterTransactionSuccess")
                        public void refresh() 
                        {
                          load();
                        }
                        
                        @Transactional
                        public void load()
                        {
                          result = em.createQuery(query).getResultList();
                        } 


                        • 9. Re: need to understand transaction:ejb-transaction

                          we switched to spring and GWT - so: no more news from me...

                          • 10. Re: need to understand transaction:ejb-transaction
                            christophea

                            Really (too) bad...