AWS ECS session replication


I’m trying to set up a data grid on AWS ECS.

I was able to get JCache working with these tutorials:

But session replication is not working. I developed a very simple JSF webapp to test based on the hajspcluster demo, it has on web.xml and the session attributes are serializable.

What am I missing?


Session test application code:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""
      <title>Facelet Title</title>
   <f:view transient="true">
         <h:form id="form">
            Key <h:inputText value="#{indexBean.key}" />
            Value <h:inputText value="#{indexBean.value}" />
            <h:commandButton value="add" action="#{indexBean.add()}" />
            <br /><br />
               <li>server: <h:outputText value="#{facesContext.externalContext.request.serverName}" /></li>
               <li>session id: <h:outputText value="#{}" /></li>
               <li>Served From Server instance: #{indexBean.instanceName}</li>
               <li>Executed Server IP Address: #{indexBean.hostAddress}</li>
            <br /><br />
            <ui:repeat id="itens" value="#{indexBean.sessionMap}" var="item">
               #{item.key} - #{item.value} <br />
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/ to edit this template
package com.mycompany.session.test;

import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.util.Map;
import javax.faces.context.FacesContext;

 * @author fjaekel
@Named(value = "indexBean")
public class IndexBean implements Serializable {

   private String key;
   private String value;
    * Creates a new instance of IndexBean
   public IndexBean() {
   public void add()
      getSessionMap().put(key, value);
   public String getInstanceName()
      return System.getProperty("com.sun.aas.instanceName");
   public String getHostAddress()
      try {
      } catch (UnknownHostException ex) {
        return ex.getMessage();                

   public String getKey() {
      return key;

   public void setKey(String key) {
      this.key = key;

   public String getValue() {
      return value;

   public void setValue(String value) {
      this.value = value;

   public Map<String, Object> getSessionMap() {
      return FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns=""
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-name>Faces Servlet</servlet-name>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-// GlassFish Application Server 3.1 Servlet 3.0//EN" "">
<glassfish-web-app error-url="">
      <session-manager persistence-type="hazelcast"> 
            <property name="relaxCacheVersionSemantics" value="true"/>

HI @fkj,

We have a blog written regarding setting up session replication in Payara Server, although the blog is written as part of a series using Apache web server, the setup should still be applicable when using AWS ECS.

The blog can be found here: Session Replication in Payara Server with Hazelcast

If you are still unable to configure session replication after following that blog, I will gladly take a further look.


I followed these steps.

I can see some action at the logs, but when I stop one of the two instances of the test the session is lost

|[#|2022-08-04T03:49:09.869+0000e[1;92m|INFO|e[0mPayara 5.2022.2|e[1;94mfish.payara.nucleus.cluster.PayaraCluster|e[0m_ThreadID=146;_ThreadName=hz.gracious_wu.event-7;_TimeMillis=1659584949869;_LevelValue=800;||
| --- | --- | --- | --- | --- | --- | --- |
|Data Grid Instance Added 69af623f-4e29-4c6f-b6e3-b342f6df6985 at Address /|#]|
|[#|2022-08-04T03:49:09.872+0000e[1;92m|INFO|e[0mPayara 5.2022.2|e[1;94mfish.payara.nucleus.cluster.PayaraCluster|e[0m_ThreadID=146;_ThreadName=hz.gracious_wu.event-7;_TimeMillis=1659584949872;_LevelValue=800;||
|Data Grid Status|
|Payara Data Grid State: DG Version: 4 DG Name: dev DG Size: 2|
|Instances: {|
|DataGrid: dev Name: server Lite: false This: true UUID: 74107202-7a29-4ae7-a840-b0f0b57f3b97 Address: /|
|DataGrid: dev Lite: false This: false UUID: 69af623f-4e29-4c6f-b6e3-b342f6df6985 Address: /|