5 Replies Latest reply on Apr 28, 2006 11:29 AM by gavin.king

    Converstaion context destroyed, why?

    baz

      Hello,
      i am currently adding Seam support to an Webapp composed with myfaces and facelets. Seam is very useful in this case. The app is easier to understand and uses lesser code.:-)

      But i have one problem for which i cannot determine the cause:
      the conversation scope is destroyed without calling a method annotated with @End.
      For the following log i will describe what i have doen in the app:
      I called this method of analysisBacking:

      @Begin(nested=true)
       public String addPCRAnalysis() {
       analysis = new PCRAnalysis();
       analysis.setExperiment(experiment);
       return "ADD_ANALYSIS";
       }
      

      It results in rendering the new page, and the conversation is correctly listed in the conversationList ( i have borrowed the list from a seam example).
      Now i am filling in some required fields and press a button which calls this method:
      @Begin(nested=true)
       public String assignSamples() {
       Set<Sample> sampleSet = analysis.getExperiment().getSampleSet();
       Set<Sample> analysisSamples = new HashSet<Sample>();
       for (Sample sample : sampleSet) {
       analysisSamples.add(sample);
       }
       sampleData.setSampleData(analysisSamples);
       getAnalysis().setSamples(analysisSamples);
       return "ASSIGN_SAMPLES";
       }
      

      Now i am on a page where i can select samples. The converstaion list shows two conversations.
      But after rendering this page, the log is like the following. The conversations seem to be destroyed.

      14:31:44,968 DEBUG org.jboss.seam.contexts.Contexts: found in conversation context: analysisBacking
      14:31:44,968 DEBUG org.jboss.seam.jsf.SeamVariableResolver: resolved name to seam component
      14:31:44,968 DEBUG org.jboss.seam.contexts.Contexts: found in session context: bazProject
      14:31:44,968 DEBUG org.jboss.seam.contexts.Contexts: found in conversation context: sampleData
      14:31:44,968 DEBUG org.jboss.seam.contexts.Contexts: found in session context: experiment
      14:31:44,968 DEBUG org.jboss.seam.jsf.SeamPhaseListener: Before saving state
      14:31:44,968 DEBUG org.jboss.seam.core.Manager: Storing conversation state: 14
      14:31:44,968 DEBUG org.jboss.seam.jsf.SeamPhaseListener: Before saving state
      14:31:44,968 DEBUG org.jboss.seam.core.Manager: Storing conversation state: 14
      14:31:44,984 DEBUG org.jboss.seam.jsf.SeamVariableResolver: resolving name: ScopeContainer
      14:31:44,984 DEBUG org.jboss.seam.Component: seam component not found: ScopeContainer
      14:31:44,984 DEBUG org.jboss.seam.jsf.SeamVariableResolver: resolved name to managed bean
      14:31:44,984 DEBUG org.jboss.seam.util.Naming: JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      14:31:44,984 DEBUG org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener: committing transaction
      14:31:44,984 DEBUG org.jboss.seam.util.Naming: JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      14:31:44,984 DEBUG org.jboss.seam.contexts.Lifecycle: After render response, destroying contexts
      14:31:44,984 DEBUG org.jboss.seam.contexts.Lifecycle: destroying event context
      14:31:44,984 DEBUG org.jboss.seam.contexts.Contexts: destroying: org.jboss.seam.core.manager
      14:31:44,984 DEBUG org.jboss.seam.contexts.Lifecycle: flushing server-side conversation context
      14:31:44,984 DEBUG org.jboss.seam.contexts.Lifecycle: <<< End web request
      14:31:44,984 DEBUG org.apache.myfaces.component.html.util.ReducedHTMLParser: DOCTYPE found at line 1
      14:31:44,984 DEBUG org.apache.myfaces.component.html.util.ReducedHTMLParser: DOCTYPE found at line 21

      So any action (button click or so) ended up in this exception:

      14:32:32,203 DEBUG org.apache.myfaces.context.servlet.ServletExternalContextImpl: Incoming request has Content-Type header without character encoding: application/x-www-form-urlencoded
      14:32:32,203 DEBUG org.jboss.seam.util.Naming: JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      14:32:32,203 DEBUG org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener: beginning transaction
      14:32:32,203 DEBUG org.jboss.seam.util.Naming: JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
      14:32:32,203 DEBUG org.jboss.seam.contexts.Lifecycle: >>> Begin web request
      14:32:32,234 DEBUG org.jboss.seam.jsf.SeamVariableResolver: resolving name: analysisBacking
      14:32:32,234 DEBUG org.jboss.seam.Component: instantiating Seam component: analysisBacking
      14:32:32,234 ERROR org.jboss.seam.servlet.SeamExceptionFilter: uncaught exception handled by Seam
      javax.servlet.ServletException: No conversation context active
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:123)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)

      I have no clue why the contexts are destroyed. This is one of several examples of this behaviour.

      On one page i could eliminate the problem simply by removing an overseen <t:savestate>
      Any help or hint will be welcome.
      What can i do to retrieve the reason why the contexts are destroyed?
      Ciao,
      Carsten


        • 1. Re: Conversation context destroyed, why?
          baz

          Hello,
          i stripped down my Bean "analysisBacking" (changing also the html pages acordingly) and are now in the task to recode it. After stripping the bean down to the absolutley basic, the app works again, but with a lose of buisinesslogic.

          I really need a hint, why seam destroyed the conversation context?
          Is there a usefull logging option?
          Does anybody has a list of donts for seam?
          Currently this list consists for me of one point

          Do not use <t:savestate>


          But in the case below i have no cue what went wrong.
          Ciao,
          Carsten

          • 2. Re: Converstaion context destroyed, why?
            gavin.king

            It does not look to me like the conversation gets destroyed.

            And you have chopped off the end of the stack trace. Unless you show the whole stack trace, I can't help you.

            • 3. Re: Converstaion context destroyed, why?
              baz

              Hello Gavin,
              here comes the complete stacktrace:


              10:21:26,234 ERROR org.jboss.seam.servlet.SeamExceptionFilter: uncaught exception handled by Seam
              javax.servlet.ServletException: No conversation context active
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:123)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:129)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
              at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
              at java.lang.Thread.run(Thread.java:595)
              10:21:26,234 DEBUG org.jboss.seam.util.Naming: JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              10:21:26,234 INFO org.jboss.seam.servlet.SeamExceptionFilter: killing transaction
              10:21:26,234 DEBUG org.jboss.seam.util.Naming: JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              10:21:26,234 DEBUG org.jboss.seam.contexts.Lifecycle: After request, destroying contexts
              10:21:26,234 DEBUG org.jboss.seam.contexts.Lifecycle: destroying event context
              10:21:26,234 DEBUG org.jboss.seam.contexts.Lifecycle: <<< End web request
              10:21:26,234 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/baz].[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
              java.lang.IllegalStateException: No conversation context active
              at org.jboss.seam.ScopeType.getContext(ScopeType.java:88)
              at org.jboss.seam.Component.newInstance(Component.java:1160)
              at org.jboss.seam.Component.getInstance(Component.java:1107)
              at org.jboss.seam.Component.getInstance(Component.java:1090)
              at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:44)
              at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:134)
              at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
              at com.sun.el.parser.AstValue.getTarget(AstValue.java:41)
              at com.sun.el.parser.AstValue.isReadOnly(AstValue.java:104)
              at com.sun.el.ValueExpressionImpl.isReadOnly(ValueExpressionImpl.java:221)
              at com.sun.facelets.el.TagValueExpression.isReadOnly(TagValueExpression.java:82)
              at com.sun.facelets.el.LegacyValueBinding.isReadOnly(LegacyValueBinding.java:82)
              at org.apache.myfaces.lifecycle.LifecycleImpl.recursivelyHandleComponentReferencesAndSetValid(LifecycleImpl.java:473)
              at org.apache.myfaces.lifecycle.LifecycleImpl.recursivelyHandleComponentReferencesAndSetValid(LifecycleImpl.java:483)
              at org.apache.myfaces.lifecycle.LifecycleImpl.recursivelyHandleComponentReferencesAndSetValid(LifecycleImpl.java:483)
              at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:181)
              at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:108)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:129)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
              at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
              at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
              at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
              at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
              at java.lang.Thread.run(Thread.java:595)

              By now i have determind another overseen artifact in my app. Before using seem i have bound the datatable component to a bean attribute
              <h:dataTable rows="20" border="1" cellspacing="2" id="sample" value="#{analysisBacking.sampleList}"
               binding="#{analysisBacking.sampleTable}" var="zeile">
              

              This leads to the above exception. After removing the useless (when using seam) binding attribute, all is running fine.

              So my list of donts include now 2 items:
              t:savestate
              binding of a datatable component

              I hope that this list does not grow to large:-)
              Ciao,
              Carsten

              • 4. Re: Converstaion context destroyed, why?
                baz

                Hello,
                now i have found out that the binding attribute does not work even on an Input component.
                I was used to use this code:

                
                 <t:inputText value="#{protokollErstellungname}" binding="#{protokollErstellung.protocolNameInput}" id="protname" styleClass="inputtext">
                
                ----------------------
                 private UIInput protocolNameInput;
                
                 getFacesContext().addMessage(protocolNameInput.getClientId(getFacesContext()),
                 Utils.getMessage("msgProtocolExist", new String[] { name }, FacesMessage.SEVERITY_ERROR));
                

                This code is decoupled from the concrete ClientId. I can put my component on any place of a page without destroying functionality.
                (JSF generate an assembled id of the ids of the component and its parents)
                As long as i can not use the binding attribute i have to use the myfaces attribute 'forceId'. But this does not delete the dependency from bean to component.

                With binding the page designer can choose which component he will bind to a specific bean (provided that bean offers a corresponding getter/setter pair)
                Wíthout binding the page designer must change both, the bean and the page, to get a component message rendered at the correct place.

                Will there be a solution? How can a bean determine the id for a component in Seam?

                Ciao,
                Carsten

                • 5. Re: Converstaion context destroyed, why?
                  gavin.king

                  As discussed in other threads (and now in the FAQ), you cannot call a conversation-scope component during the JSF RESTORE_VIEW phase. Use a component from some other scope.