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

    Sometimes error messages shown only after page refresh

    Alexander Pavlov Newbie

      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!