Infrastructure
Context
Session scoped
bean named Login
which contain one field email
.Hazelcast
, the bean is only instantiated one time and keep its values.Login
bean is deserialized at each execution phase (the memory address change, and the set email is not kept).How we noticed
The login page was throwing "fields are empty" message while they were actually set. We then debugged more into this and found out that the bean is re-instantiated at each phase (using a PhaseListener).
Note that if we change the bean scope to request or view, the fields will be recognized, but it is not an option in the actual context.
Is Hazelcast overriding the way JSF handle session scoped bean ? If not, why is this happening ?
Edit : The bean does implement Serializable
TL;DR
Add this init param to Hazelcast web filter :
<init-param>
<param-name>deferred-write</param-name>
<param-value>true</param-value>
</init-param>
You should be aware when you use Hazelcast session replication with JSF that every time ELResolver try to get a reference to a session bean Hazelcast will deserialized it for him. This is why your Login bean is being deserialized at each execution phase.
However Hazelcast WebFilter have a parameter called "deferred-write" that if set to true will cache the instance into a local map and give it to you directly from there. and at the end of every http request WebFilter will write all values stored on this map to Hazelcast.