6 Replies Latest reply on May 28, 2008 10:31 AM by lmk

    ViewExpiredException

      Browsing the demo on: http://livedemo.exadel.com/richfaces-demo/richfaces/sortingFeature.jsf, wait until your session times out (The time-out is probably set to 30 min), then click on an action and you will get:

      ...
      exception
      
      javax.servlet.ServletException: viewId:/richfaces/sortingFeature.jsf - View /richfaces/sortingFeature.jsf could not be restored.
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      
      root cause
      
      javax.faces.application.ViewExpiredException: viewId:/richfaces/sortingFeature.jsf - View /richfaces/sortingFeature.jsf could not be restored.
       com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:186)
       com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      


      As I have read, this exception is normal for jsf 1.2 (so I think it is not a richfaces problem) and has to be catched in some way, but I couldn't find a nice way to do it. To be honest, I was hoping to find the solution in the source of the richfaces demo...

      So I'm asking you clever guys... :-)



        • 1. Re: ViewExpiredException
          fabmars
          • 2. Re: ViewExpiredException
            lmk

            to turn around it
            you can implement JSF PhaseListener

            on the afterPhase function

            logger.info("AFTER " + e.getPhaseId());
            
            PhaseId phaseid = e.getPhaseId();
            FacesContext context = e.getFacesContext();
            HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
            
            HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
            if (phaseid == PhaseId.RESTORE_VIEW || phaseid == PhaseId.INVOKE_APPLICATION) {
            
             if (context.getViewRoot() == null) {
             try {
             response.sendRedirect("login.jsf");
             } catch (IOException e1) {
            
            
             }
            
             }
            


            this works..waiting the end of developpement..


            • 3. Re: ViewExpiredException

              It works well for 'normal' jsf requests, but not for ajax requests...

              This is what happens when clicking on an ajax-enabled action after session expiration:

              restore view, view root == /login.xhtml
              render response, view root = /login.xhtml

              -> login page is shown in browser (FF3.0, IE6)

              after login:

              restore view, view root == null -> response.sendRedirect(request.getContextPath());

              A blank page is shown in browser:

              <?xml version="1.0" encoding="UTF-8"?>
              <html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="Ajax-Response" content="redirect" /><meta name="Location" content="/xenturion-mmi" /></head></html>
              
              


              • 4. Re: ViewExpiredException
                lmk

                are you using facelets or not?

                • 5. Re: ViewExpiredException

                  Yes,
                  facelets 1.1.14
                  myfaces 1.2.2
                  tomahawk 1.1.6

                  • 6. Re: ViewExpiredException
                    lmk

                     

                    "meurisse" wrote:
                    Yes,
                    facelets 1.1.14
                    myfaces 1.2.2
                    tomahawk 1.1.6


                    I think when ajax request is sent after sessionExpired, there exist special message on the faces context added by a4j viewHandler.
                    if you find what's the message you can workaround this problem..

                    it's just a temporary solution wainting the end of the correction.