title: javax.faces.application.ViewExpiredException seemingly ignored
body: <p>I've put the following into my web.xml:</p>
  
  <pre><code>    &lt;error-page&gt;
      &lt;exception-type&gt;javax.faces.application.ViewExpiredException&lt;/exception-type&gt;
      &lt;location&gt;/expiredIndex.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  &lt;error-page&gt;
      &lt;exception-type&gt;java.lang.Throwable&lt;/exception-type&gt;
      &lt;location&gt;/error.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  &lt;session-config&gt;
      &lt;session-timeout&gt;1&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>
  
  <p>When I start my app, and wait for 1 minute, if I then attempt to interact with it (JSF 1.2, <code>h:commandButton</code>) I get the error</p>
  
  <pre><code> SEVERE: Servlet.service() for servlet Faces Servlet threw exception
  javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
      at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Can someone tell me why it is the <code>javax.faces.application.ViewExpiredException</code> is not being picked up?  I'm looking for the most basic expiry setup possible and surely that's all that is necessary in the web descriptor.</p>
  
  <p>Thanks</p>
  
  <p><em>EDIT</em></p>
  
  <p>I now have in my web.xml the following:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;Error&lt;/filter-name&gt;
      &lt;filter-class&gt;myClient.ErrorFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;Error&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
      &lt;error-page&gt;
          &lt;exception-type&gt;javax.servlet.ViewExpiredException&lt;/exception-type&gt;
          &lt;location&gt;/expiredIndex.jsf&lt;/location&gt;
      &lt;/error-page&gt;
  </code></pre>
  
  <p>(these entries are the last filter entries in the web.xml) and a new filter with the doFilter method as described in <a href="https://stackoverflow.com/questions/3206922/issue-with-jsf-viewexpiredexception-and-multiple-error-page-tag-definitions-in-we">this</a> post.  What should be happening now is the <code>rootCause</code> should unwrap the ViewExpiredException which should thus redirect the user to my <code>expiredIndex</code> page when the servlet session times out.  Instead I get a 500.  I can't see what else to I need to do the correct redirect in this situation.  Help!</p>
  
  <p><em>EDIT 2</em></p>
  
  <p>Error from the 500 is:</p>
  
  <pre><code>javax.faces.application.ViewExpiredException: viewId:/index.jsf - View /index.jsf could not be restored.
      com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:185)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
      com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      prismClient.ErrorFilter.doFilter(Unknown Source)
  </code></pre>
  
  <p>which I guess is the standard one.</p>