How do I cluster the ServletContext

The Servlet Specification version 2.4 states in section SRV.3.2:

In cases where the container is distributed over many virtual machines, a Web application will have an instance of the ServletContext for each JVM.

The specification further clarifies the distributed scope of ServletContext attributes in section SRV.3.4.1:

Context attributes are local to the JVM in which they were created. This prevents ServletContext attributes from being a shared memory store in a distributed container. When information needs to be shared between servlets running in a distributed environment, the information should be placed into a session (See Chapter SRV.7, Sessions), stored in a database, or set in an Enterprise JavaBeans component.

Coherence*Web is fully compliant to the Servlet Specification, and as a result, it does not cluster ServletContext attributes by default. However, it does have an option to allow ServletContext attributes to be shared across multiple JVMs. Using this option, only those attributes which can be successfully serialized will be shared across multiple JVMs.

To configure the ServletContext to be clustered, edit the coherence-web.xml that is produced from the inspection step of the Coherence*Web Installer. Set the coherence-servletcontext-clustered parameter to true.