6 Replies Latest reply on Jun 27, 2008 7:04 PM by brma

    Out-jected variables available for rendering but not for submit

    brma

      Dear all,


      I'm meanwhile some weeks with Seam and it seams to be a great framework - however, there is an issue i'm not managing to resolve for more than a week now.


      My configuration:




      • JBoss 4.2.2.GA

      • Seam 2.0.2 SP1



      My issue:



      in my application there are two entities (Portfolio, PortfolioTargetBSC) which have a one-to-one JTA relation - Portfolio is the leading part. I have a form for every entity for editing the details. There is a button in portfolio.xhtml (editing page for Portfolio) that calls the function begin(portfolio) in the action bean that prepares PortfolioTargetBSC (PortfolioTargetBSCAction). After the preparation the request is redirected via pages.xml to targetPortfolioBSC.xhtml. The context variables are filled and the information is rendered correctly (can be seen in the form) in targetPortfolioBSC.xhtml but when the page is submitted later on the error says that portfolioTargetBSC what was out-jected before cannot be found in the context.
      Further interesting is that I explicitely start a long term conversation with @Begin but the log says the stateful bean is destroyed - also debug.seam shows no conversation... any help would be highly appreciated.


      Source files are below:


      PortfolioTargetBSCActionBean.java


      @Stateful
      
      @Name("portfolioTargetBSCAction")
      
      public class PortfolioTargetBSCActionBean implements PortfolioTargetBSCActionInterface
      
      {
      
      
           @Logger
      
           private Log log;
      
      
           @PersistenceContext(type = EXTENDED)
      
           private EntityManager em;
      
      
           @In(required = false)
      
           @Out(required = false)
      
           private Portfolio bscPortfolio;
      
           
      
           @In(required = false)
      
           @Out(required = true)
      
           private PortfolioTargetBSC portfolioTargetBSC;
      
           
      
           public PortfolioTargetBSCActionBean()
      
           {
      
           }
      
           
      
           @Begin
      
           public void begin(Portfolio pPortfolio)
      
           {
      
                this.bscPortfolio = em.find(Portfolio.class, pPortfolio.getId());
      
                portfolioTargetBSC = bscPortfolio.getPortfolioTargetBSC();
      
           }
      
      
           @End
      
           public String update()
      
           {
      
                bscPortfolio.setPortfolioTargetBSC(portfolioTargetBSC);
      
                bscPortfolio = em.merge(bscPortfolio);
      
                
      
                return ("success");
      
           }
      
           
      
           @End
      
           public String cancel()
      
           {
      
                return ("success");
      
           }
      
      
           @Remove
      
           @Destroy
      
           public void destroy()
      
           {
      
                log.info("Why am I dead???");
      
           }
      
      }



      Target xhtml-file (targetPortfolioBSC.xhtml) - rendered correctly but throws exception at submit:


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      
                                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      
           xmlns:s="http://jboss.com/products/seam/taglib"
      
           xmlns:ui="http://java.sun.com/jsf/facelets"
      
           xmlns:f="http://java.sun.com/jsf/core"
      
           xmlns:h="http://java.sun.com/jsf/html"
      
           xmlns:a4j="http://richfaces.org/a4j"
      
           xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
      
      
           <ui:define name="body">
      
      
                <h:messages globalOnly="true" styleClass="message" />
      
      
                <h:form id="bscForm">
      
      
                     <rich:panel>
      
                          <f:facet name="header">BSC Targets for Portfolio: #{bscPortfolio.name}</f:facet>
      
                          <div class="actionButtons"><h:commandButton value="Save"
      
                               action="#{portfolioTargetBSCAction.update}" /> <a4j:commandButton
      
                               value="Cancel" action="#{portfolioTargetBSCAction.cancel}"
      
                               bypassUpdates="true" /></div>
      
                          <div><rich:panel>
      
                               <f:facet name="header">Financials</f:facet>
      
                               <s:decorate template="layout/edit.xhtml">
      
                                    <ui:define name="label">IT investments</ui:define>
      
                                    <h:selectOneMenu value="#{portfolioTargetBSC.titInvestments}">
      
                                         <s:selectItems value="#{portfolioTargetBSC.typeTarget}"
      
                                              var="targetType" label="#{targetType}" />
      
                                    </h:selectOneMenu>
      
                                    <rich:spacer height="10" width="10" />
      
                                    <h:inputText required="false"
      
                                         value="#{portfolioTargetBSC.itInvestments}" />
      
                               </s:decorate>
      
      
      ...
      
      
                               </rich:panel></div>
      
      
                          <div style="clear: both" />
      
      
                     </rich:panel>
      
      
                </h:form>
      
      
           </ui:define>
      
      
      </ui:composition>
      
      
      



      Logfile:


      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.Component] trying to inject with hierarchical context search: bscPortfolio
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.contexts.Contexts] found in conversation context: bscPortfolio
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.Component] trying to inject with hierarchical context search: portfolioTargetBSC
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.contexts.Contexts] found in conversation context: portfolioTargetBSC
      
      ...
      
      2008-06-26 22:32:51,640 INFO  [cc.brandstaetter.PPM.session.PortfolioTargetBSCActionBean] Why am I dead???
      
      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.bscPortfolio
      
      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.bscPortfolio
      
      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.portfolioTargetBSC
      
      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.portfolioTargetBSC
      
      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preRemoveVariable.portfolioTargetBSCAction
      
      ...
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postRemoveVariable.portfolioTargetBSCAction
      
      2008-06-26 22:32:51,640 DEBUG [org.jboss.seam.ejb.RemoveInterceptor] Stateful component was removed: portfolioTargetBSCAction



      Exception thrown at submit:


      Exception during request processing: 
      
      Caused by javax.servlet.ServletException with message: "/targetPortfolioBSC.xhtml @27,69 value="#{portfolioTargetBSC.titInvestments}": Target Unreachable, identifier 'portfolioTargetBSC' resolved to null" 
      
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
      
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
      
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
      
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
      org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
      
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      
      java.lang.Thread.run(Unknown Source)


        • 1. Re: Out-jected variables available for rendering but not for submit
          norman

          So, I guess the real question is why your conversation isn't being started.  Can you verify that begin() is called?  If you display #{conversation.longRunning} in the view, does it show as long running?

          • 2. Re: Out-jected variables available for rendering but not for submit
            brma

            Hello Norman,


            first of all thanks for the fast reply!



            Can you verify that begin() is called?

            Definitely YES! The name shown in #{bscPortfolio.name} always shows the right name to the passed pPortfolio in begin(Portfolio pPortfolio).



            If you display #{conversation.longRunning} in the view, does it show as long running?

            I tried this but unfortunatelly the answer is NO! :(


            Perhaps one further question:
            Is there any possibility to see if the conversation was even created and dropped again later on (although it didn't pass a @End) or never created? The log didn't show me anything significant...


            Thanks a lot in advance!!!
            Regards, Markus

            • 3. Re: Out-jected variables available for rendering but not for submit
              brma

              A further annotation: not only #{bscPortfolio.name} is filled correctly but also all other fields from portfolioTargetBSC show the same values as they are stored in the database - this implies for me that



              @Begin
              
                      public void begin(Portfolio pPortfolio)
              
                      {
              
                              this.bscPortfolio = em.find(Portfolio.class, pPortfolio.getId());
              
                              portfolioTargetBSC = bscPortfolio.getPortfolioTargetBSC();
              
                      }
              
              


              works. At least besides the creation of the long-run conversation.... :(

              • 4. Re: Out-jected variables available for rendering but not for submit
                brma

                Some further information: meanwhile I found the opening and the closing of the long-running conversation in the log file. Unfortunatelly it does not tell me what closes the long-running conversation... :(


                Any ideas? Find the lines from the log below.
                Thanks in advance for any feedback!


                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.core.Manager] Beginning long-running conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preSetVariable.org.jboss.seam.core.conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postSetVariable.org.jboss.seam.core.conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postCreate.org.jboss.seam.core.conversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.beginConversation
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.contexts.Contexts] found in conversation context: org.jboss.seam.persistence.persistenceContexts
                
                2008-06-27 13:06:59,734 DEBUG [org.jboss.seam.core.Manager] Ending long-running conversation


                • 5. Re: Out-jected variables available for rendering but not for submit
                  dahm

                  Hi,


                  my guess would be that the variable is outjected in the wrong context (i.e., not in the conversation). Have you tried
                  to set an explicit scope in the @Out tag or define the session bean as conversational scoped?


                  Cheers
                     Markus

                  • 6. Re: Out-jected variables available for rendering but not for submit
                    brma

                    Gentlemen,


                    first of all thank you very much for all the comments and helps!
                    I managed to resulve the issue by myself and would like to describe the solution for others that might experience the same issue:


                    In the first step I found out that the conversation started with @Begin was terminated immediately. The reason seamed to be because Seam obviously had decided BEFORE that the bean that issued the @Begin should be destroyed and the long-time conversation was destroyed with it. This could be prevented by removing the @Begin and using a <begin-conversation/> in pages.xml instead.


                    However - this is not the end of the story. The bean calling the bean I had the trouble with kept an @Entity object in the conversation context, I did not do anything with when leaving the context and THIS caused the context to be dropped!


                    Lesson learned: do not leave an @Entity object unmanaged when leaving the actual context!


                    Thanks a lot for the help provided!
                    Regards, Markus