You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Mario Ivankovits <ma...@ops.co.at> on 2006/01/11 20:26:01 UTC

JFYI: change session to request bean - the way life

(Sorry for the crosspost, initially my intention was to post it on ther 
user list but selected the wrong address)

Hi!

It cost me a couple of hours to figure it out, so I'll share my insights 
with you.

I have had a bean which I declared in session scope at first.
After a while I decided to make it a request scoped bean and use the 
managed-property stuff to inject a request param.

I restarted tomcat a couple of times but never got this request 
parameter injected.

Why ...?

The solution was:
Tomcat stores all session variables in its work directory in a file 
named SESSIONS.ser.
Even after restarting tomcat my OLD session scoped bean were 
reinitialized from this file. Now that myfaces found the bean in session 
scope there was no need to recreate it and thus the request param werent 
injected.

After removing this SESSIONS.ser all worked as expected.

Hope this will sometimes save someones time.

Ciao,
Mario


RE: JFYI: change session to request bean - the way life

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
I was just thinking along the lines of some(?) previous poster recommending we (JSF Programmers) use "scope names dot
managed bean names" in our JSF/JSP files to ensure scope conflicts like this never happen.  Perhaps this was a good
example of that for debugging purposes. :)

Regards,
David

-----Original Message-----
From: Mario Ivankovits [mailto:mario@ops.co.at]
Sent: Thursday, January 12, 2006 1:50 AM
To: MyFaces Discussion
Subject: Re: JFYI: change session to request bean - the way life


Hi David!
> So you never did a session.invalidate() or removed the object from the session?  Not before your removal of the
sessions
> file?
>
No, why should I?
During development I often restart tomcat, but not more.
Once I figured out the bean is still in session scope the first idea I
had was to remove the file, sure, there are a couple of ways to remove
the object from the session.


After thinking about this topic even more, another solution could haven
been to simply restart the browser, then the session cookie will be lost
and a new session will be created.

Ciao,
Mario


Re: JFYI: change session to request bean - the way life

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi David!
> So you never did a session.invalidate() or removed the object from the session?  Not before your removal of the sessions
> file?
>   
No, why should I?
During development I often restart tomcat, but not more.
Once I figured out the bean is still in session scope the first idea I 
had was to remove the file, sure, there are a couple of ways to remove 
the object from the session.


After thinking about this topic even more, another solution could haven 
been to simply restart the browser, then the session cookie will be lost 
and a new session will be created.

Ciao,
Mario


RE: JFYI: change session to request bean - the way life

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Mario,

So you never did a session.invalidate() or removed the object from the session?  Not before your removal of the sessions
file?

Regards,
David

-----Original Message-----
From: Mario Ivankovits [mailto:mario@ops.co.at]
Sent: Wednesday, January 11, 2006 2:26 PM
To: MyFaces Discussion
Subject: JFYI: change session to request bean - the way life


(Sorry for the crosspost, initially my intention was to post it on ther
user list but selected the wrong address)

Hi!

It cost me a couple of hours to figure it out, so I'll share my insights
with you.

I have had a bean which I declared in session scope at first.
After a while I decided to make it a request scoped bean and use the
managed-property stuff to inject a request param.

I restarted tomcat a couple of times but never got this request
parameter injected.

Why ...?

The solution was:
Tomcat stores all session variables in its work directory in a file
named SESSIONS.ser.
Even after restarting tomcat my OLD session scoped bean were
reinitialized from this file. Now that myfaces found the bean in session
scope there was no need to recreate it and thus the request param werent
injected.

After removing this SESSIONS.ser all worked as expected.

Hope this will sometimes save someones time.

Ciao,
Mario