HTTP Sessions and Failover of Web Applications

Use

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

  • 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.SessionConte xt .

    • Reference to naming contexts.

    • Reference to javax.transaction.UserTransaction .

  • Enterprise JavaBeans serialization is done by the EJB Container.

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