You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joao Batistella <jo...@ptinovacao.pt> on 2004/03/19 10:47:22 UTC

Session not destroyed after server shutdown

Hello!

I'm using Tomcat 4 and all sessions that I have when the server is up are
not
destroyed when I shutdown te server. I've implemented a
ServletContextListener
to register when the app is going down and a HttpSessionListener to see when
a session is destroyed. When the server goes down the sessions are not
destroyed and, when it comes up again, the sessions are still there. If I
try to get a session attribute by some key before setting the same attribute
I have a result different of null.
Anyone knows what is this?

My sofwate versions:
Windows XP Professional
Tomcat 4.1.29-LE
J2sdk 1.4.2

Thanks,
JP

Re: Session not destroyed after server shutdown

Posted by Daryl Stultz <da...@6degrees.com>.
"Tomcat Users List" <to...@jakarta.apache.org> writes:
> You can
>always delete the work directory for the app if you actually do desire to
>blow
>away sessions as well.

I have scripts to restart Tomcat which do precisly that because...

>> destroyed and, when it comes up again, the sessions are still there. If
>I
>> try to get a session attribute by some key before setting the same
>attribute
>> I have a result different of null.

I also have a HttpSessionListener that lets me view active user
statistics. It builds a list of sessions as they are created and
destroyed. When Tomcat restarts, the list of sessions is empty - naturally
since the sessions are still presumably active yet sessions are added to
my list only when created. Is there a way to get all the currently active
sessions so I can rebuild the list when Tomcat restarts? (If so, I
probably don't need the listener...)

Thanks.

Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Session not destroyed after server shutdown

Posted by Jacob Kjome <ho...@visi.com>.
Quoting Christian Cryder <ch...@granitepeaks.com>:

> Hi Jake!
> 
> But this means everything you put in the session needs to be serializable,
> right?
> 

Yep, a recommended best practice.  If you need to put something in the session
and it has data that isn't serializable, make it implement Serializable and
either make the member variable transient or use a static variable.

Consider another case where you are distributing sessions over multiple
appservers.  The data *must* be serializable in that case just as it must be
serializable to write it to the current server's disk upon server shutdown.  So,
the bottom line is, if it isn't serializable and you put it in the session, your
app is likely to not be compatible under certain conditions in certain environments.

> I don't think this impacts Barracuda (because I don't think its saving
> anything in the session - just creating the OR wrappers over the session),
> but we might want to check.
> 
> Of course, we can continue that conversation on the bmvc list...
> 

Sure. 

later,

Jake

> Christian
> ----------------------------------------------
> Christian Cryder
> Internet Architect, ATMReports.com
> Project Chair, BarracudaMVC - http://barracudamvc.org
> ----------------------------------------------
> "Coffee? I could quit anytime, just not today"
> 
> 
> > -----Original Message-----
> > From: Jacob Kjome [mailto:hoju@visi.com]
> > Sent: Friday, March 19, 2004 10:20 AM
> > To: Tomcat Users List
> > Subject: Re: Session not destroyed after server shutdown
> >
> >
> > Sessions aren't destroyed until the session times out.  If you
> > shut the server
> > down, existing sessions will be written to file.  If you bring
> > the server back
> > up before the timeout of those sessions, they will still exist upon server
> > restart.  If you think about it, this is usually desired
> > behavior.  I believe
> > you can turn this off on the Coyote connector, but I've forgotten
> > how.  I can't
> > imagine why you wouldn't want it to work this way.  What if you were doing
> > emergency server maintainance and had to restart the app while
> > some users were
> > connected.  Blowing away their sessions would normally be
> > undesired.  You can
> > always delete the work directory for the app if you actually do
> > desire to blow
> > away sessions as well.
> >
> > Jake
> >
> > Quoting Joao Batistella <jo...@ptinovacao.pt>:
> >
> > > Hello!
> > >
> > > I'm using Tomcat 4 and all sessions that I have when the server
> > is up are
> > > not
> > > destroyed when I shutdown te server. I've implemented a
> > > ServletContextListener
> > > to register when the app is going down and a
> > HttpSessionListener to see when
> > > a session is destroyed. When the server goes down the sessions are not
> > > destroyed and, when it comes up again, the sessions are still
> > there. If I
> > > try to get a session attribute by some key before setting the
> > same attribute
> > > I have a result different of null.
> > > Anyone knows what is this?
> > >
> > > My sofwate versions:
> > > Windows XP Professional
> > > Tomcat 4.1.29-LE
> > > J2sdk 1.4.2
> > >
> > > Thanks,
> > > JP
> >
> > ---------------------------------------------------------------------
> > 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

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Session not destroyed after server shutdown

Posted by Christian Cryder <ch...@granitepeaks.com>.
Hi Jake!

But this means everything you put in the session needs to be serializable,
right?

I don't think this impacts Barracuda (because I don't think its saving
anything in the session - just creating the OR wrappers over the session),
but we might want to check.

Of course, we can continue that conversation on the bmvc list...

Christian
----------------------------------------------
Christian Cryder
Internet Architect, ATMReports.com
Project Chair, BarracudaMVC - http://barracudamvc.org
----------------------------------------------
"Coffee? I could quit anytime, just not today"


> -----Original Message-----
> From: Jacob Kjome [mailto:hoju@visi.com]
> Sent: Friday, March 19, 2004 10:20 AM
> To: Tomcat Users List
> Subject: Re: Session not destroyed after server shutdown
>
>
> Sessions aren't destroyed until the session times out.  If you
> shut the server
> down, existing sessions will be written to file.  If you bring
> the server back
> up before the timeout of those sessions, they will still exist upon server
> restart.  If you think about it, this is usually desired
> behavior.  I believe
> you can turn this off on the Coyote connector, but I've forgotten
> how.  I can't
> imagine why you wouldn't want it to work this way.  What if you were doing
> emergency server maintainance and had to restart the app while
> some users were
> connected.  Blowing away their sessions would normally be
> undesired.  You can
> always delete the work directory for the app if you actually do
> desire to blow
> away sessions as well.
>
> Jake
>
> Quoting Joao Batistella <jo...@ptinovacao.pt>:
>
> > Hello!
> >
> > I'm using Tomcat 4 and all sessions that I have when the server
> is up are
> > not
> > destroyed when I shutdown te server. I've implemented a
> > ServletContextListener
> > to register when the app is going down and a
> HttpSessionListener to see when
> > a session is destroyed. When the server goes down the sessions are not
> > destroyed and, when it comes up again, the sessions are still
> there. If I
> > try to get a session attribute by some key before setting the
> same attribute
> > I have a result different of null.
> > Anyone knows what is this?
> >
> > My sofwate versions:
> > Windows XP Professional
> > Tomcat 4.1.29-LE
> > J2sdk 1.4.2
> >
> > Thanks,
> > JP
>
> ---------------------------------------------------------------------
> 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


Re: Session not destroyed after server shutdown

Posted by Jacob Kjome <ho...@visi.com>.
Sessions aren't destroyed until the session times out.  If you shut the server
down, existing sessions will be written to file.  If you bring the server back
up before the timeout of those sessions, they will still exist upon server
restart.  If you think about it, this is usually desired behavior.  I believe
you can turn this off on the Coyote connector, but I've forgotten how.  I can't
imagine why you wouldn't want it to work this way.  What if you were doing
emergency server maintainance and had to restart the app while some users were
connected.  Blowing away their sessions would normally be undesired.  You can
always delete the work directory for the app if you actually do desire to blow
away sessions as well.

Jake

Quoting Joao Batistella <jo...@ptinovacao.pt>:

> Hello!
> 
> I'm using Tomcat 4 and all sessions that I have when the server is up are
> not
> destroyed when I shutdown te server. I've implemented a
> ServletContextListener
> to register when the app is going down and a HttpSessionListener to see when
> a session is destroyed. When the server goes down the sessions are not
> destroyed and, when it comes up again, the sessions are still there. If I
> try to get a session attribute by some key before setting the same attribute
> I have a result different of null.
> Anyone knows what is this?
> 
> My sofwate versions:
> Windows XP Professional
> Tomcat 4.1.29-LE
> J2sdk 1.4.2
> 
> Thanks,
> JP

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org