Issue
When a customization stores a session attribute that is not serializable, this error appears in the Liferay logs:
[ERROR] SerializableSessionAttributeListener - [Name.Of.The.Custom.Class] is not serializable and will prevent this session from being replicated
Environment
- Liferay DXP 7.0+
Resolution
WARNING
The following resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.
This message is expected.
SerializableSessionAttributeListenerchecks each attribute added to the session, and thesession.verify.serializable.attributeportal property controls that check:Set this to true to allow com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener to test if an added session variable is serializable. Unserializable values stored into the session will cause a session to not replicate if session replication was enabled by the application server. Defaults: session.verify.serializable.attribute=true
- To resolve the issue, update the customization so every object it stores in the session implements
java.io.Serializable. Once it does, the session replicates normally. - In case you assume the behavior or don't have session replication configured on the application server and would like to stop seeing the message on the log, you can change said property to false in your portal-ext.properties file. However this is not a permanent solution and will not solve the issue. It only stops the class
com.liferay.portal.kernel.servlet.SerializableSessionAttributeListenerfrom verifying session variables.