11 Replies Latest reply on Oct 3, 2005 12:26 PM by deniss.parhomenko

    Tomahawk and Seam problem

    deniss.parhomenko

      I take one example from myfaces (pagedSortTable.jsf), remove bean defenition from faces-config.xml and add to bean followong definition:

      @Name("pagedSort")
      @Scope(SESSION)

      in this configuration evrything works fine, but if i add
      @Intercept(InterceptionType.ALWAYS)

      when i click on sortable header i receive exception
      22:54:30,243 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.IllegalStateException: No conversation context active
       at org.jboss.seam.ScopeType.getContext(Unknown Source)
       at org.jboss.seam.Component.newInstance(Unknown Source)
       at org.jboss.seam.Component.getInstance(Unknown Source)
       at org.jboss.seam.Component.getInstanceToInject(Unknown Source)
       at org.jboss.seam.Component.injectFields(Unknown Source)
       at org.jboss.seam.Component.inject(Unknown Source)
       at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor123.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Unknown Source)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Unknown Source)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(Unknown Source)
       at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Unknown Source)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Unknown Source)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(Unknown Source)
       at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor121.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Unknown Source)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Unknown Source)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(Unknown Source)
       at org.jboss.seam.interceptors.BusinessProcessInterceptor.manageBusinessProcessContext(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Unknown Source)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Unknown Source)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(Unknown Source)
       at org.jboss.seam.interceptors.RemoveInterceptor.removeIfNecessary(Unknown Source)
       at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Unknown Source)
       at org.jboss.seam.interceptors.Interceptor.aroundInvoke(Unknown Source)
       at org.jboss.seam.interceptors.SeamInvocationContext.proceed(Unknown Source)
       at org.jboss.seam.ejb.SeamInterceptor.aroundInvoke(Unknown Source)
       at org.jboss.seam.interceptors.JavaBeanInterceptor.interceptInvocation(Unknown Source)
       at org.jboss.seam.interceptors.JavaBeanInterceptor.intercept(Unknown Source)
       at org.apache.myfaces.examples.listexample.PagedSortableCarList$$EnhancerByCGLIB$$1a07367d.toString(<generated>)
       at java.lang.String.valueOf(String.java:2577)
       at java.lang.StringBuffer.append(StringBuffer.java:220)
       at org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:155)
       at com.sun.facelets.el.LegacyELContext$LegacyELResolver.setValue(LegacyELContext.java:197)
       at com.sun.el.parser.AstValue.setValue(AstValue.java:113)
       at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:246)
       at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:93)
       at com.sun.facelets.el.LegacyValueBinding.setValue(LegacyValueBinding.java:68)
       at org.apache.myfaces.component.html.ext.HtmlDataTable.restoreState(HtmlDataTable.java:473)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:511)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
       at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
       at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreComponentState(JspStateManagerImpl.java:129)
       at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:185)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:319)
       at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:113)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
       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.SeamExceptionFilter.doFilter(Unknown Source)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       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.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       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:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      

      JSP:
      <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:t="http://myfaces.apache.org/tomahawk">
       <jsp:text>
      <html>
      <head>
       <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8"/>
       <title>MyFaces - the free JSF Implementation</title>
       <link rel="stylesheet" type="text/css" href="css/basic.css"/>
      </head>
      
      
      <body>
      
      
      <f:view>
      
       <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
       <h:form>
       <t:dataTable id="data"
       styleClass="scrollerTable"
       headerClass="standardTable_Header"
       footerClass="standardTable_Header"
       rowClasses="standardTable_Row1,standardTable_Row2"
       columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
       var="car"
       value="#{pagedSort.cars}"
       preserveDataModel="true"
       rows="10"
       rowId="#{car.type}"
       rowOnClick="alert('rowId: ' + this.id)"
       sortColumn="#{pagedSort.sort}"
       sortAscending="#{pagedSort.ascending}"
       preserveSort="true">
       <h:column>
       <f:facet name="header"><h:outputText value="#{car.id}" /></f:facet>
       <h:outputText value="#{car.id}" />
       </h:column>
       <h:column>
       <f:facet name="header">
       <t:commandSortHeader columnName="type" arrow="true" immediate="false">
       <h:outputText value="#{example_messages['sort_cartype']}" />
       </t:commandSortHeader>
       </f:facet>
       <h:outputText value="#{car.type}" />
       </h:column>
       <h:column>
       <f:facet name="header">
       <t:commandSortHeader columnName="color" arrow="true" immediate="false">
       <h:outputText value="#{example_messages['sort_carcolor']}" />
       </t:commandSortHeader>
       </f:facet>
       <h:inputText value="#{car.color}" >
       <f:validateLength maximum="10"/>
       </h:inputText>
       </h:column>
       </t:dataTable>
      
       <h:panelGrid columns="1" styleClass="scrollerTable2" columnClasses="standardTable_ColumnCentered" >
       <t:dataScroller id="scroll_1"
       for="data"
       fastStep="10"
       pageCountVar="pageCount"
       pageIndexVar="pageIndex"
       styleClass="scroller"
       paginator="true"
       paginatorMaxPages="9"
       paginatorTableClass="paginator"
       paginatorActiveColumnStyle="font-weight:bold;">
       <f:actionListener type="org.apache.myfaces.examples.listexample.DataScrollerActionListener"/>
       <f:facet name="first" >
       <t:graphicImage url="images/arrow-first.gif" border="1" />
       </f:facet>
       <f:facet name="last">
       <t:graphicImage url="images/arrow-last.gif" border="1" />
       </f:facet>
       <f:facet name="previous">
       <t:graphicImage url="images/arrow-previous.gif" border="1" />
       </f:facet>
       <f:facet name="next">
       <t:graphicImage url="images/arrow-next.gif" border="1" />
       </f:facet>
       <f:facet name="fastforward">
       <t:graphicImage url="images/arrow-ff.gif" border="1" />
       </f:facet>
       <f:facet name="fastrewind">
       <t:graphicImage url="images/arrow-fr.gif" border="1" />
       </f:facet>
       </t:dataScroller>
      
       </h:panelGrid>
       </h:form>
      </f:view>
      
      
      </body>
      
      </html></jsp:text>
      </jsp:root>
      

      May be somebody can help me?

        • 1. Re: Tomahawk and Seam problem
          gavin.king

          It's not possible to invoke a conversation-scope Seam component from RESTORE_VIEW. Actually invoking any component from RESTORE_VIEW seems pretty wierd.

          I'm not sure why JSF is trying to do that...

          • 2. Re: Tomahawk and Seam problem

             

            "gavin.king@jboss.com" wrote:
            It's not possible to invoke a conversation-scope Seam component from RESTORE_VIEW. Actually invoking any component from RESTORE_VIEW seems pretty wierd.

            I'm not sure why JSF is trying to do that...


            Some components either: as immediate or as supporting events, may attempt to invoke methods in any phase-- not necessarily as proper actions. Even if Seam's interceptor is properly decorating based on the current phase, maybe Seam should default the behavior such that if conversation scoped, and no conversation, store in request/event scope. I know it sounds horrible, another option would be to by default, have a conversation running-- this may lead into some of the nested/inherited conversation ideas.

            • 3. Re: Tomahawk and Seam problem
              gavin.king

              But the problem is that there is no way to get at a conversation scoped bean until after Restore View, since we can't get at the conversation id until the component tree has been fully restored.

              Unless ... do you know if there is some expectation that the view root will be restored before any other component?

              • 4. Re: Tomahawk and Seam problem

                Deniss,

                The problem you are seeing is most likely from:

                <t:dataTable preserveDataModel="true">...</t:dataTable>


                • 5. Re: Tomahawk and Seam problem

                  Deniss,

                  The problem you are seeing is most likely from:

                  <t:dataTable preserveDataModel="true">...</t:dataTable>


                  MyFaces' Extended DataTable is trying to fire off changes to the model during restoreState, before the complete component model is available to Seam. Changes to the model really should be occuring at decode phase. The restoreState is meant for restoring the component tree, that's it. The decode phase occurs after the component state is restored, now allowing the component tree to fully interact with your model (via EL). The Extended DataTable breaks this contract within the restore state phase, before the decode phase.

                  Now, in relation to Seam. Seam's concept of a conversation is carried with the component model. When components like the Extended DataTable try to access conversation-scoped Objects before the component model is restored, you get the exception you posted. Simply put, Seam is properly handling the phases of JSF, while the Extended DataTable is not.

                  Which beans are you specifying as conversation scoped?

                  • 6. Re: Tomahawk and Seam problem
                    gavin.king

                    Jacob and I discussed this, and Jacob noted that the preserveDataModel functionality was implemented in a class called DataModelHack or something like that, which does not inspire great confidence ;-)

                    But, after reading the documentation for preserveDataModel, it seems that there is no good reason to ever use preserveDataModel="true" with a conversation scope bean. A conversation-scoped object already "preserves" its state! So if you just set preserveDataModel="false", you should be good to go.

                    • 7. Re: Tomahawk and Seam problem
                      deniss.parhomenko

                      Thanks for your replies.


                      I haven't any conversation scoped bean, I have only one Session bean

                      @Name("pagedSort")
                      @Scope(SESSION)

                      and thats all. Later i'll try to remove preserveDataModel="true" and inform you about result. But this jsp and bean are taken from myfaces examples without changing.

                      • 8. Re: Tomahawk and Seam problem
                        gavin.king

                        You definitely have a conversation scope component *somewhere*. Looks like it is being injected into a field of the component that is being invoked by JSF. Some field of the component is marked @In(create=true).

                        Note that some types of Seam components are conversation scope by default. (SFSBs and entity beans.) So it is probably an entity or SFSB.

                        • 9. Re: Tomahawk and Seam problem
                          deniss.parhomenko

                          Yes, it could be, I have @In(create=true) in my bean:
                          @In(create=true)
                          private Session bookingDatabase
                          , but that all, as i remember, sorry i can't check it now :(.

                          Latr i'll create a simple war with one bean and one page and check how it works.

                          • 10. Re: Tomahawk and Seam problem
                            gavin.king

                            Right, bookingDatabase is a Seam-managed session - a conversation-scope Seam component.

                            So, conclusion is, remove preserveDataModel="true", it is unneeded, and perhaps a bit dodgy to begin with.



                            package org.jboss.seam.core;
                            ...

                            @Scope(ScopeType.CONVERSATION)
                            @Intercept(NEVER)
                            public class ManagedHibernateSession implements Serializable { ... }

                            • 11. Re: Tomahawk and Seam problem
                              deniss.parhomenko

                              Yep,preserveDataModel="false" and preserveSort="false" helps.

                              Thank you.