Avatar of willa666
willa666
Flag for United States of America asked on

HttpSession serialization

What triggers Weblogic to serialize the session? We are having an issue where an instance of an object that is put in session is not available when session state is restored via deserialization because the class des not implement the Serializable interface. We are going to modify the class to implement Serializable, however, it is unclear to us why the app server is deciding to store session state to disk.

Note that we have been deploying the application to a specific node of a clustered weblogic install for a while, but did not start to see this issue until today.
Java App Servers

Avatar of undefined
Last Comment
Becky

8/22/2022 - Mon
mbvvsatish

good article on "Session Management for Clustered Applications"
http://dev2dev.bea.com/pub/a/2005/05/session_management.html

this will provide the answer for you
:)
Ajar

WebLogic Serializes the session objects during replicating them on other servers in a cluster.  The objects that you put in session should be serializable along with all the fields in them. If certain fields are not serializable, e.g Output Stream, Socket etc then declare that field as transiet.  

ASKER CERTIFIED SOLUTION
Ajar

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Becky

Everything you put into an http session (and everything Weblogic may put into the session on the back end) will automatically (attempted to) be serialized by the appserver when appserver participates in a cluster.

So very simply, the answer to your question "What triggers Weblogic to serialize the session?" is the Servlet specification.  That specification states what appservers can and cannot to do be J2EE compliant.  With regard to sessions, the appservers must attempt to serialize all data stored in the session.  You can choose the *storage* methodology (be it in memory, database, disk, etc..) but the appserver does the actual serialization.  I believe the default storage for Weblogic is in memory, so really it's trying to store those objects in the appserver cache.  It can store non-serializable objects in its in-memory cache, but if that server fails those objects weren't passed to other members of the cluster so you will lose them.

That's why it's critical to ensure all your session objects can be serialized.   Ajar's code will help you to test session-stored objects.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck