I am working with an J2EE application and i need to save some object (non serialized) into session as an attribute. This is not creating problem on Myeclipse but after hosting the application if after creating some session we change some java files then it throws exception something want to say that we should not store the non serialized object into persisted sessions and session got empty.
Is there any way to forcibly save the non serialized object into session as attribute without creating this type of problems.
It depends on your app and your deployment.
If you're clustering with session replication, binding non-serializable objects to session will prevent replication from working.
Also if you need to be able to restart an application (or the container) without killing your users's session this could cause a problem as some containers (Tomcat for one) achieve this by serializing the whole session to disk when the app shuts down and then deserializes them when the app starts back up.
Also, if your container is storing session information in a database, it will need to be able to serialize them.
Why can't you implement Serializible?
What are you holding in these objects that can't be serialized?
Actually i have stored the connection object in session within another object that is to be stored but i have removed this object from that class now.
Thank for the help.
Now i need one more help. as you have said that it is vendor specific where it will store the session data either in file on disk or in database, is it possible that tomcat save context attributes as well somewhere and reload them on server startup like session attributes.
Is there any alternative way to achieve this something by using context linstener and overriding method named contextinitialized and contextdestroyed.
I think this will solve the problem but is there any direct way to save the object to some file and again load from the file in java.