title: IOException while loading persisted sessions on Tomcat 6.0
body: <p>We have an application in flex which is deployed on load balanced Tomcat 6.0 (There is a load balancer which is passing the request to 2 tomcat servers).</p>
  
  <p>We are getting a 404 error while access the application. On digging through the tomat logs we found the following error</p>
  
  <p><strong>Log Trace</strong></p>
  
  <pre><code>2013-01-17 10:42:54,148 org.apache.catalina.session.ManagerBase - IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: bean.Login
  java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: bean.Login
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)
          at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
  ..
  2013-01-17 10:43:04,135 org.apache.catalina.session.ManagerBase - Exception loading sessions from persistent storage
  java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: bean.Login
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)
          at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
  …
  Caused by: java.io.NotSerializableException: bean.Login
          at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
  </code></pre>
  
  <p><strong>Cause</strong></p>
  
  <p>Possible reason for this error is Tomcat tries to serialize the full object graph of all active sessions when you shut it down, and then it tries to restore them when you start it back up. The crux of this is that Tomcat uses "normal" java object serialization, which requires all objects to be Serializable.</p>
  
  <p>We have mapped the Login bean in Spring as following</p>
  
  <pre><code>&lt;bean id="currLogin" class="bean.Login" scope="session"&gt;
        &lt;aop:scoped-proxy /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>Remedy</strong></p>
  
  <p><strong>Short Term</strong></p>
  
  <ul>
  <li>Delete the file session.ser in the catalina_home/work directory   </li>
  <li>Restart the tomcat servers</li>
  </ul>
  
  <p>we are able to login to the application without the error after bouncing the server.</p>
  
  <p><strong>Long Term</strong></p>
  
  <ul>
  <li>Make bean.Login serializable by implementing the Serializable
  interface.</li>
  <li>Don't have Tomcat serializing sessions (add 
  to the context.xml, either in the app or in the global tomcat
  context.xml in the conf/ directory, inside the  element.</li>
  </ul>
  
  <p>Please let us know the approach to resolve this issue?</p>