Serialization issues using HazelCast with session scoped bean

Infrastructure

  • JSF 2.1.17 (Mojarra)
  • Hazelcast 3.3
  • JBoss EAP 6.3

Context

  • Session scoped

    bean named Login

    that contain one field email

    .
  • When deployed without a Hazelcast

    bean, it is created only once and retains its values.
  • When adding Hazelcast to the application, we noticed that the Login

    bean is deserialized at every stage of execution (changing the memory address, and the given letter is not saved).

As we noticed

On the login page, the message "fields are empty" was selected while they were installed. We then debugged this and found out that the bean is re-instantiated in each phase (using a PhaseListener).

Note that if we change the scope of the bean to query or view, the fields will be recognized, but this is not an option in real context.

Is Hazelcast overriding how JSF handles a session bean? If not, why is this happening?

Edit: bean implementsSerializable

+3


source to share


1 answer


TL; DR

Add this init parameter to your Hazelcast web filter:

<init-param>
    <param-name>deferred-write</param-name>
    <param-value>true</param-value>
</init-param>

      



You should be aware when using JSF Hazelcast Session Replication, every time ELResolver tries to get a reference to the session bean, Hazelcast will deserialize it for it. This is why your bean login is deserialized at every stage of execution.

However, the Hazelcast WebFilter has a "write-back" parameter that, if set to true, will cache the instance to the local map and pass it to you directly from there. and at the end of every HTTP request, the WebFilter will write all the values ​​stored in this map to Hazelcast.

+1


source







All Articles