title: @SessionScoped JSF bean in Google App engine loses state
body: <p>I'm trying to use JSF on Google App Engine, but I'm running into some trouble when using a Sessionscoped bean. I have a class annotated as @Sessionscoped, and just a single page with only a next button on it in a form. When I click this button in Eclipse the value of currentNumber gets updated every time, which is what I would expect. But when it's deployed on the App Engine the number gets reset to 0 for every request so it nevers gets past 1. No matter what I do I can't seem to get session behaviour, it always acts as if it is requestscoped. It works fine locally, but not when deployed. Any ideas anyone?</p>
  
  <pre><code>import java.io.Serializable;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.SessionScoped;
  
  
  @ManagedBean(name = "controller")
  @SessionScoped
  public class Controller implements Serializable {
  
  
          private int currentNumber;
  
  
      public Controller() {
  
      }
  
      public int getCurrentNumber() {
          return currentNumber;
      }
  
      public void setCurrentNumber(int currentNumber) {
          this.currentNumber = currentNumber;
      }
  
      public void next() {
          currentNumber++;
      }
  }
  </code></pre>
  
  <p>In appengine.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;appengine-web-app xmlns="http://appengine.google.com/ns/1.0"&gt;
      &lt;version&gt;1&lt;/version&gt;
  
      &lt;!-- Allows App Engine to send multiple requests to one instance in parallel: --&gt;
      &lt;threadsafe&gt;true&lt;/threadsafe&gt;
  
      &lt;!-- Configure java.util.logging --&gt;
      &lt;system-properties&gt;
          &lt;property name="java.util.logging.config.file" value="WEB-INF/logging.properties" /&gt;
      &lt;/system-properties&gt;
      &lt;sessions-enabled&gt;true&lt;/sessions-enabled&gt;
  
  &lt;/appengine-web-app&gt;
  </code></pre>
  
  <p>And finally web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt;&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
     &lt;!-- ***** Designate client-side state saving. *****  --&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;
     &lt;!-- Set the default suffix for JSF pages to .xhtml --&gt;
     &lt;context-param&gt;
        &lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
        &lt;param-value&gt;.xhtml&lt;/param-value&gt;
     &lt;/context-param&gt;
     &lt;!-- Disable use of threading for single-threaded environments such as
          the Google AppEngine. --&gt;
     &lt;context-param&gt;
        &lt;param-name&gt;com.sun.faces.enableThreading&lt;/param-name&gt;
        &lt;param-value&gt;false&lt;/param-value&gt;
     &lt;/context-param&gt;
     &lt;!-- ***** Specify JBoss Expression Language Over Default --&gt;
     &lt;context-param&gt;     
        &lt;param-name&gt;com.sun.faces.expressionFactory&lt;/param-name&gt;
        &lt;param-value&gt;org.jboss.el.ExpressionFactoryImpl&lt;/param-value&gt;   
     &lt;/context-param&gt; 
     &lt;!-- ***** Load the JavaServer Faces Servlet ***** --&gt;
     &lt;servlet&gt;
        &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
        &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
     &lt;/servlet&gt;
     &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
        &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
     &lt;/servlet-mapping&gt;
     &lt;!-- ***** Specify session timeout of thirty (30) minutes. ***** --&gt;
     &lt;session-config&gt;
        &lt;session-timeout&gt;30&lt;/session-timeout&gt;
     &lt;/session-config&gt;
   &lt;servlet&gt;
    &lt;servlet-name&gt;SystemServiceServlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.google.api.server.spi.SystemServiceServlet&lt;/servlet-class&gt;
    &lt;init-param&gt;
     &lt;param-name&gt;services&lt;/param-name&gt;
     &lt;param-value/&gt;
    &lt;/init-param&gt;
   &lt;/servlet&gt;
   &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;SystemServiceServlet&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/_ah/spi/*&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>Changing jsf implementation from the one mentioned in Mykongs tutorial to Mojarra's 2.0.3 version mysteriously did the trick. If anyone has any clue why that would happen I'd love to know, because I haven't seen it mentioned anywhere.</p>