title: Random JSF error: no saved view state could be found
body: <p>I have a very strange error: No saved view state could be found for the view identifier: /mypage.xhtml<br>
  The problem is that it appears randomly, to just ~10% of the users/executions.</p>
  
  <p>Application server: Apache Tomee 1.5.2 stable / 1.6.0-2013.09.20 dev (It happens on both). I use the MyFaces distribution that comes with each of them, so 2.1.10 / 2.1.12, so nothing new added.</p>
  
  <p>Part of web.xml:</p>
  
  <pre><code>      &lt;context-param&gt;
          &lt;param-name&gt;org.apache.myfaces.USE_ENCRYPTION&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
        &lt;/context-param&gt;
        &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
          &lt;param-value&gt;client&lt;/param-value&gt;
        &lt;/context-param&gt;
  </code></pre>
  
  <p>So, no state view exception shouldn't happen, because state is on client. It was set on server before, but I thought maybe client will fix it, but nothing. There was actually no difference in the occurrence of that error.</p>
  
  <p>Execution flow:<br>
  1. Client opens xhtml page (JSF).<br>
  2. Client clicks on an command button to do various things, button connected to a public void method of a JSF @ViewScoped ManagedBean.<br>
  3. Yes, the method is void because I don't need to return a String to redirect to another page. I need to redirect to /page/id (example: /market/24, /profile/43), therefore methods that return a String as navigation destinations are useless, because I use: <code>FacesContext.getCurrentInstance().getExternalContext().redirect(path);</code><br>
  4. In ~90% of the cases, everything works perfectly and users are redirected to each specific page. In the rest of ~10 (randomly), they get <code>No saved view state could be found for the view identifier: /pagename.xhtml</code></p>
  
  <p>I would really appreciate some help here, because I have no idea how to get it fixed.<br>
  Thanks a lot in advance.</p>
  
  <p>PS. I use PrimeFaces and I also have a couple of my own filters in web.xml, but that shouldn't be a problem, I hope so.</p>
  
  <p>Stack trace for one of the pages:  </p>
  
  <pre><code>25-Sep-2013 07:39:26.380 SEVERE [http-bio-80-exec-15] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [] threw exception [/dashboard/edit-profile.xhtmlNo saved view state could be found for the view identifier: /dashboard/edit-profile.xhtml] with root cause
   javax.faces.application.ViewExpiredException: /dashboard/edit-profile.xhtmlNo saved view state could be found for the view identifier: /dashboard/edit-profile.xhtml
          at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:132)
          at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
          at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:77)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:199)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at com.pingushare.boundary.filter.ActivateAccountFilter.doFilter(ActivateAccountFilter.java:37)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at com.pingushare.boundary.filter.SecurityFilter.doFilter(SecurityFilter.java:36)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at com.pingushare.boundary.filter.ForceFreshPageAndWWWFilter.doFilter(ForceFreshPageAndWWWFilter.java:49)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
          at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:724)
  </code></pre>