Wednesday, August 19, 2009

Tomcat Sessions and Java objects

Just ran into a problem today where we had a Java Object with transient member variables put into Tomcat's session. According to this thread in Java Ranch (http://www.coderanch.com/t/86379/Tomcat/Problems-disabling-Session-Persistence-Manager), objects put into session should implement Serializable. Member variables which are transient will not be preserved when being retrieved from session, and should be commented as such. This has lead to a few bugs in my code and was a gotcha that I never really thought of before, but makes perfect sense. Hopefully next time I will remember.

No comments:

Post a Comment