Show TOC

Background documentationHTTP Sessions and Failover of Web Applications Locate this document in the navigation structure

 

If you want to develop a distributed, failover-ready Web application, you have to make HTTP sessions persistent. That is, HttpSession objects are serialized and stored in a file.

HTTP Sessions Serialization on the AS Java

If application failover is not enabled, serialization is performed:

  • When the server that processes the requests is shut down.

  • When the Web Container Service is stopped.

  • When the application is stopped.

If application failover is enabled (if you have set it in the application-j2ee-engine.xml application descriptor), serialization is performed:

  • After completing each request associated with the HTTP session (if you have activated the failover with the on_request attribute in the application-j2ee-engine.xml of your application).

    Note Note

    If the client has not received a response (for example, the server node has crashed after completing the request, but before sending the response back to the client), this state is not serialized. Serialization is performed after the last successfully executed response.

    End of the note.
  • When the server that processes the requests is shut down.

  • When the Web Container Service is stopped.

  • When the application is stopped.

  • After setAttribute() and removeAttribute() methods of the HttpSession (if you have activated the failover with the on_attribute attribute in the application-j2ee-engine.xml of your application).

Programming Requirements for HTTP Sessions Persistency
  • Store only serializable objects in the session. Exceptions to this rule are the following objects:

    • References to enterprise beans interfaces.

    • Reference to javax.ejb.SessionContext.

    • Reference to naming contexts.

    • Reference to javax.transaction.UserTransaction.

      Note Note

      Do not store database or network connections - they cannot be serialized. If you are using JDBC connections, they must be closed and set to null, so that session is serialized. You can use the sessionWillPassivate method of the HttpSessionActivationListener interface to receive events when the session is about to be passivated.

      End of the note.
  • Enterprise JavaBeans serialization is done by the EJB Container.

  • Do not store large objects into the session because the application overhead becomes significant.