4 Replies Latest reply on Jan 17, 2008 12:10 PM by avpavlov

    Sometimes error messages shown only after page refresh

    avpavlov

      Hi folks!

      I faced strange behaviour when tried to display error page for all uncatched exceptions: sometimes error messages are displayed, sometimes I see empty error page and need refresh page to see messages.

      My error page

      <ui:composition template="/jspx/template.jspx"
       xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core">
       <ui:define name="pageContent">
       <f:view>
       <h:form>
       <p>
       There has been an error.
       </p>
       <h:messages/>
       </h:form>
       </f:view>
       </ui:define>
      </ui:composition>
      


      Global exceptions handler declared in pages.xml
       <exception>
       <redirect view-id="/error.jspx">
       <message>
       Unrecoverable error. If you edited some data then these have not been saved. Details:
       #{org.jboss.seam.handledException.message}
       </message>
       </redirect>
       </exception>
      


      Seam debug mode and facelet development mode are disabled.

      How I tested: Open form and enter duplicate value to unique field, JDBC driber throws ConstraintViolation exception, it successfully propagated to declared handler, it successfully adds error message to FacesMessages.instance(), and redirects to error.jspx BUT when page opens I sometimes do not see messages and need to refresh page.

      Looks like there is some racing between handled exception processing and next page rendering - sometimes messages are added BEFORE page rendered and all is ok, sometimes page rendered BEFORE messages added and I need refresh.

      Under debugger all works fine (as I understand my breakpoints suspends page rendering so there is no racing).

      What to do?

      Thanks in advance!

        • 1. Re: Sometimes error messages shown only after page refresh
          pmuir

          If you can attach an example to allow us to reproduce the issues to a JIRA issue we can take a look. I know there are problems in this area.

          • 2. Re: Sometimes error messages shown only after page refresh
            avpavlov

            Hi Pete.

            In what form do you expect example? deployable ear? or just files involved to this bug, i.e. bean definition, page source, controller source and etc?

            Our deployable ear is about 5Mb.

            • 3. Re: Sometimes error messages shown only after page refresh
              pmuir

              Preferably something that just shows the problem, with source code and a build script.

              • 4. Re: Sometimes error messages shown only after page refresh
                avpavlov

                Looks like messages added to old conversation, after error Seam opens new BUT keeps old conversation id in URL. After refreshing Seam returns to old conversation and displays messages.

                See some debug logs below

                Legend
                
                FMhash is org.jboss.seam.faces.FacesMessages component instance hash code
                
                RT = org.jboss.seam.faces.FacesMessages.runTasks()
                END_CNV = org.jboss.seam.exception.RedirectHandler.handle()/Conversation.instance().end()
                REDIRECT=org.jboss.seam.faces.Navigator.redirect()/FacesManager.instance().redirect
                BRR = org.jboss.seam.faces.FacesMessages.beforeRenderResponse()
                


                ... I opened NESTED conversation and I did something that produces SQLException ...
                RT conversationId=5, FMhash=26790826
                END_CNV conversationId=5
                REDIRECT conversationId=5
                BRR conversationId=6 (!!!!!), FMhash=7429444 (!!!!!)
                
                At this point error page is opened, NO error messages, URL contains conversationId=5
                
                ... I refreshed page ...
                RT conversationId=5, FMhash=26790826
                END_CNV conversationId=5
                REDIRECT conversationId=5
                BRR conversationId=5, FMhash=26790826
                
                At this point error page refreshed and contains missed messages
                


                Looks like there is redirection failure while exception processed.