You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Francisco J. León" <fl...@cantv.net> on 2005/04/21 16:50:43 UTC
Tomcat "forgets" a session attribute when reloading context
Hi 'catters. I am having a small but annoying behavior in Tomcat.
Tested on
5.0.28 and 5.5.9. I posted this as bug 34547 but a developer thinks
it's not a bug.
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.
session.setAttribute("logged_user_name",username);
session.setAttribute("permission",permissions);
if (user!=null) {
session.setAttribute("userpreferences",user);
}
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
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.
--
Francisco Javier León Arosemena
X Semestre de Lic. en Computación
Maracaibo, Edo. Zulia, Venezuela
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Tomcat "forgets" a session attribute when reloading context
Posted by Mike Curwen <g_...@globallyboundless.com>.
It's possible that your User object is not serializing correctly. As I
understand things: when contexts are reloaded, the sessions are serialized
first, the context reloads, and the sessions are restored from their
serialized form. If one of your attributes doesn't make it through this
process, then the Session itself is not invalidated; you just don't get that
particular attribute back. I've seen this happen on my own web-app.
> -----Original Message-----
> From: Francisco J. León [mailto:fleona@cantv.net]
> Sent: Thursday, April 21, 2005 9:51 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Tomcat "forgets" a session attribute when reloading context
>
>
> Hi 'catters. I am having a small but annoying behavior in Tomcat.
> Tested on
> 5.0.28 and 5.5.9. I posted this as bug 34547 but a developer thinks
> it's not a bug.
>
> 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.
>
> session.setAttribute("logged_user_name",username);
> session.setAttribute("permission",permissions);
>
> if (user!=null) {
> session.setAttribute("userpreferences",user);
> }
>
> 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
>
> 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.
>
> --
> Francisco Javier León Arosemena
> X Semestre de Lic. en Computación
> Maracaibo, Edo. Zulia, Venezuela
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org