Preserving Beans between Application Restarts


Web tier: servlets, JSP, Web frameworks: Preserving Beans between Application Restarts

  1. Hello!

    We are using Tomcat 5 for development. The authentication mechanism works as follow:

    A filter intercepts each reqest to check if it is a login request. If it is an authentication request, it is validated and in case of success, a bean is filled and attached to session. The servlet checks whether this bean exists in the session for authentication.

    Whenever the web application is restarted from manager web app or by autodetection of changes due to setting reloadable=true in context, The bean becomes null.

    To my understanding, tomcat should preserve sessions when application is restarted without restarting tomcat itself. Is there any special reason for not keeping beans between web application restarts?

  2. Is your user bean Serializable? Tomcat retains session data by serializing it and storing it to the hard disk between restarts, but only for serializable objects.

    BTW, you should not store password info in the session for this very reason: it will be written to disk if the session is saved by the server.
  3. Solved[ Go to top ]

    Thanks for pointing that out. I actually missed implementing Serializable interface. Now it is working.