Bug 34547 - Tomcat "forgets" a session attribute when reloading context
Summary: Tomcat "forgets" a session attribute when reloading context
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: 5.5.9
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2005-04-21 04:11 UTC by Francisco Le
Modified: 2005-04-21 12:45 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Francisco Le 2005-04-21 04:11:12 UTC
Hi 'catters. I am having a small but annoying behavior in Tomcat. Tested on
5.0.28 and 5.5.9

I use Eclipse 3.02 for development, along the Sysdeo Tomcat Plugin and
Freemarker for MVC. My context path is set to be reloadable, and when i am
coding, if i make some change to the code, the context gets reloaded by the
plugin, and a session attribute gets null'ed.

The weirdest thing is that not all of the session attributes are nulled. Just
this one we will call "user".

I will try to explain what happens with pseudocode.

When the users log on to my application, this happens:

ForumUser user = run_sql_here;

ForumUser is a bean with some properties. That query stores:
-a user id (int)
-a timezone (string)
-a language (string)

All of the other attributes in the object are not used at this time.


if (user!=null) {

This is the ONLY time that attribute gets set. It ONLY gets removed when the
session is invalidated.

When i change code and the context gets reloaded, the "user" attribute gets
null, and the other 2 attributes (permission and logged_user_name) are OK

If i don't reload the context, everything is OK.

Does anyone have any idea of what is going on?

Do you guys need my code? I will gladly do whatever test you need me to
do to resolve this. It is very annoying to keep logging out and back in to test
new code so my session gets corrected
Comment 1 Francisco Le 2005-04-21 04:13:36 UTC
Oh sorry i should have mentioned that i use java 1.4.2_07 on linux (arch linux),
kernel 2.6.11 with glibc 2.3.4 with NTPL
Comment 2 Remy Maucherat 2005-04-21 08:54:25 UTC
Please post on tomcat-user instead, as this does not look like a bug.
Comment 3 Francisco Le 2005-04-21 16:46:15 UTC
Why this doesn't look like a bug? Tomcat deletes an object in my session. If it would delete all objects, 
then i wouldn't have posted this, since i would have thought that reloading a context would delete the 
whole session.

I think my code is ok since i just set that attribute (the one that gets null) at login.
Comment 4 Tim Funk 2005-04-21 18:18:37 UTC
Custom objects which do not implement java.io.Serializable cannot be persisted
across restarts. There should be a message in the logs stating so. Use
tomcat-user  for more details.

Bugzilla is not a support forum/help desk.
Comment 5 Francisco Le 2005-04-21 20:45:36 UTC
Yes, i asked in the list and indeed that was the problem. I of course know
bugzilla isn't a help desk, i only posted this because i thought it was a bug,
since my other objects in the session were plain strings and weren't
experiencing this behavior. That probably means strings implement Serializable
or something and i wasn't aware of that.

Thanks for the help! :)