8 Replies Latest reply on Sep 6, 2011 8:20 AM by hantsy

    How to end a long run converstation...

    hantsy

      In seam2, there are several ways to exit the current long run conversation...


      How to do in Seam3?


      For example,


      a country list page, there a link to edit country page at the same time, it begin a long run conversation, in the edit page there are two buttons, save and cancel to end the conversation...


      But the problem is, if in the edit page, I click the list page...the url will append a cid on it...and caused some problem on other actions in the list page...

        • 1. Re: How to end a long run converstation...
          ssachtleben.ssachtleben.gmail.com

          Use s:viewAction to invoke a method and start the conversation like this:


          @Inject Conversation conversation;
          
          public void start() {
            if (conversation.isTransient()) {
              conversation.start();
            }
          }
          
          public void end() {
            if (!conversation.isTransient()) {
              conversation.end();
            }
          }



          • 2. Re: How to end a long run converstation...
            hantsy

            OK, I pasted some codes here... I used Seam 3 @Begin and @End in the edit page...but some time the list link directly, not click the save and cancel to end the conversation...it will append the cid to the list page url...


            In the seam 2 there is s:link has a propagation attribute( set value to 'end') to end the conversation.



            
            @Stateful
            @ConversationScoped
            @Named("portEdit")
            public class PortEditAction {
            
            
                    @PersistenceContext
                    EntityManager em;
            
                    @Inject
                    Logger log;
            
                    private Port currentPort;
            
                    @Inject
                    private Event<Port> portSavedEventSrc;
            
                    @Inject
                    Messages messages;
            
                    public Port getCurrentPort() {
                            return currentPort;
                    }
            
                    public void setCurrentPort(Port currentPort) {
                            this.currentPort = currentPort;
                    }
            
                    @Begin()
                    public void initAdd() {
                            if (log.isDebugEnabled()) {
                                    log.debug("call init...");
                            }
            
                            this.currentPort = new Port();
            
                    }
            
                    @Begin
                    public void initEdit(Port port) {
                            if (log.isDebugEnabled()) {
                                    log.debug("call initEdit...@" + port);
                            }
                            this.currentPort = port;
                    }
            
                    
                    @End
                    public void save() {
                            if (log.isDebugEnabled()) {
                                    log.debug("call save...");
                            }
            
                            if (this.currentPort.getId() == null) {
                                    em.persist(this.currentPort);
                            } else {
                                    this.currentPort = em.merge(this.currentPort);
                            }
            
                            this.portSavedEventSrc.fire(this.currentPort);
                    }
            
                    public void onSaved(
                                    @Observes(during = TransactionPhase.AFTER_SUCCESS) Port port) {
                            messages.info(new DefaultBundleKey("port_saved"))
                                            .defaults("Port saved").params(port.getName());
                    }
            
            
                    @End
                    public void cancel() {
                            if (log.isDebugEnabled()) {
                                    log.debug("call end...");
                            }
            
                    }
            }
            
            

            • 3. Re: How to end a long run converstation...
              ssachtleben.ssachtleben.gmail.com

              Please post the jsf part of list link...

              • 4. Re: How to end a long run converstation...
                hantsy


                <rich:menuItem label="Ports"
                                    action="/addressee/portList?faces-redirect=true"
                                    icon="/images/icons/open.gif" />




                Another problem I found, when returned form the edit page...when click the add link...


                The url became like this


                http://localhost:8080/siorc/addressee/portEdit.xhtml?cid=23&cid=23
                



                There are two cid in the url...and an exception in page...


                javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: WELD-000214 Attempt to call begin() on a long-running conversation
                     at org.jboss.seam.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:73)
                     at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
                     at org.jboss.seam.faces.component.UIViewAction.broadcast(UIViewAction.java:381)
                     at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
                     at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
                     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
                     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
                     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                     at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                     at org.jboss.seam.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                     at org.jboss.seam.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
                     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
                     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)
                     at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
                     at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)
                     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
                     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
                     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
                     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
                     at java.lang.Thread.run(Thread.java:662)
                Caused by: javax.ejb.EJBTransactionRolledbackException: WELD-000214 Attempt to call begin() on a long-running conversation
                     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:158)
                     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:237)
                     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363)
                     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219)
                     at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                     at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                     at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
                     at com.telopsys.siorc.addressee.PortEditAction$$$view65.select(Unknown Source)
                     at sun.reflect.GeneratedMethodAccessor1389.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
                     at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
                     at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
                     at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
                     at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:125)
                     at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62)
                     at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
                     at com.telopsys.siorc.addressee.PortEditAction$Proxy$_$$_Weld$Proxy$.select(PortEditAction$Proxy$_$$_Weld$Proxy$.java)
                     at com.telopsys.siorc.addressee.PortEditAction$Proxy$_$$_WeldClientProxy.select(PortEditAction$Proxy$_$$_WeldClientProxy.java)
                     at sun.reflect.GeneratedMethodAccessor1468.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:735)
                     at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
                     at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:246)
                     at org.apache.el.parser.AstValue.invoke(AstValue.java:192)
                     at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                     at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
                     at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
                     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
                     at org.jboss.seam.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:63)
                     ... 35 more
                Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-000214 Attempt to call begin() on a long-running conversation
                     at org.jboss.weld.context.conversation.ConversationImpl.begin(ConversationImpl.java:100)
                     at sun.reflect.GeneratedMethodAccessor1397.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)
                     at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
                     at org.jboss.weld.proxies.Conversation$2129994391$Proxy$_$$_WeldClientProxy.begin(Conversation$2129994391$Proxy$_$$_WeldClientProxy.java)
                     at org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor.beginConversation(ConversationBoundaryInterceptor.java:116)
                     at org.jboss.seam.faces.context.conversation.ConversationBoundaryInterceptor.around(ConversationBoundaryInterceptor.java:58)
                     at sun.reflect.GeneratedMethodAccessor1378.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                     at java.lang.reflect.Method.invoke(Method.java:597)
                     at org.jboss.interceptor.proxy.InterceptorInvocation$InterceptorMethodInvocation.invoke(InterceptorInvocation.java:72)
                     at org.jboss.interceptor.proxy.SimpleInterceptionChain.invokeNextInterceptor(SimpleInterceptionChain.java:82)
                     at org.jboss.weld.bean.InterceptorImpl.intercept(InterceptorImpl.java:98)
                     at org.jboss.as.weld.ejb.DelegatingInterceptorInvocationContext.proceed(DelegatingInterceptorInvocationContext.java:70)
                     at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.delegateInterception(Jsr299BindingsInterceptor.java:99)
                     at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:112)
                     at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:122)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:132)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
                     at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:61)
                     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
                     at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)
                     at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233)
                     ... 71 more
                

                • 5. Re: How to end a long run converstation...
                  ssachtleben.ssachtleben.gmail.com

                  Please try a casual h:link with outcome to your list view and check if the behaviour is the same as rich:menuItem.


                  For the stacktrace try:




                         @Inject Conversation conversation;
                  
                          @Begin()
                          public void initAdd() {
                                  if (log.isDebugEnabled()) {
                                          log.debug("call init...");
                                  }
                                  if (conversation.isTransient()) {
                                          conversation.start();
                                  }
                                  this.currentPort = new Port();
                  
                          }
                  
                          public void initEdit(Port port) {
                                  if (log.isDebugEnabled()) {
                                          log.debug("call initEdit...@" + port);
                                  }
                                  if (conversation.isTransient()) {
                                          conversation.start();
                                  }
                                  this.currentPort = port;
                          }
                  
                          public void save() {
                                  if (log.isDebugEnabled()) {
                                          log.debug("call save...");
                                  }
                                  if (this.currentPort.getId() == null) {
                                          em.persist(this.currentPort);
                                  } else {
                                          this.currentPort = em.merge(this.currentPort);
                                  }
                                  this.portSavedEventSrc.fire(this.currentPort);
                                  if (!conversation.isTransient()) {
                                          conversation.end();
                                  }
                          }
                  
                          public void cancel() {
                                  if (log.isDebugEnabled()) {
                                          log.debug("call end...");
                                  }
                                  if (!conversation.isTransient()) {
                                          conversation.end();
                                  }
                          }



                  • 6. Re: How to end a long run converstation...
                    ssachtleben.ssachtleben.gmail.com

                    Remove the first @Begin() too.


                    I hate the missing edit button here :(

                    • 7. Re: How to end a long run converstation...
                      hantsy

                      I have tried like this, it became stable...but other problems is still there...I have posted in another topic.

                      • 8. Re: How to end a long run converstation...
                        hantsy