4

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).

We are getting a 404 error while access the application. On digging through the tomat logs we found the following error

Log Trace

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)

Cause

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.

We have mapped the Login bean in Spring as following

<bean id="currLogin" class="bean.Login" scope="session">
      <aop:scoped-proxy />
</bean>

Remedy

Short Term

  • Delete the file session.ser in the catalina_home/work directory
  • Restart the tomcat servers

we are able to login to the application without the error after bouncing the server.

Long Term

  • Make bean.Login serializable by implementing the Serializable interface.
  • 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.

Please let us know the approach to resolve this issue?

Leandro
  • 17
  • 6
Jyotirup
  • 2,652
  • 9
  • 28
  • 36

1 Answers1

5

I believe if you want Tomcat to persist objects in Session between restarts you will need to implement the Serializable interface. Pretty much you have answered your own question.

It is up to you whether you want them persisted between restarts or not.

cowls
  • 22,178
  • 6
  • 45
  • 76