You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by David Thielen <da...@thielen.com> on 2003/03/28 21:58:34 UTC

HttpSessionBindingListener.valueUnbound() not called

Hi;

I have an object that implements HttpSessionBindingListener. It calls
valueBound fine. But it never calls valueUnbound. Not when it times out and
not when Tomcat is closed. I am running 4.1.18.

Any ideas?

thanks - dave


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


Re: HttpSessionBindingListener.valueUnbound() not called

Posted by David Thielen <da...@thielen.com>.
That makes a lot of sense - thank you.

- dave


----- Original Message -----
From: "Hans Bergsten" <ha...@gefionsoftware.com>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Sunday, March 30, 2003 5:54 PM
Subject: Re: HttpSessionBindingListener.valueUnbound() not called


> David Thielen wrote:
> > One note to the below:
> >
> > It does call it on a timeout under 4.1.24 (it did not do that in
4.1.18).
> > But it does not call it if Tomcat is reloaded or exits - which according
to
> > the spec it is supposed to do.
>
> Two things:
> 1) When you stop Tomcat, it saves all session data to disk; it does not
>     terminate the sessions at this time, so don't expect a valueUnbound()
>     call immediately at stop. When Tomcat is restarted, it loads all
>     session data again and eventually calls valueUnbound() when it finds
>     that the session has timed out. Also note that it only checks for
>     timeouts every 1 second, so that's the shortest time-out value that
>     is honored.
> 2) In order to save and reload the session data, all objects in the
>     session must be serializable, e.g. implement java.io.Serializable.
>     Your FileList class doesn't, so it can be saved and reloaded, hence
>     the valueUnbound() method is never called after a restart.
>
> Arguably, there's still a bug here. There's a comment in the Standard-
> Session class for the method that saves the session data that any object
> that is not serializable "will be unbound from the session, with
> appropriate actions if it implements HttpSessionBindingListener," which
> I assume mean valueUnbound() will be called. I don't see any signs of
> this being done, however. You may want to file a bug report about this.
>
> For a class that implements Serializable, however, everything seems to
> work as it should in 4.1.24.
>
> Hans
>
> > ----- Original Message -----
> > From: "David Thielen" <da...@thielen.com>
> > To: ""Hans Bergsten"" <ha...@gefionsoftware.com>
> > Cc: "Tomcat - dev" <to...@jakarta.apache.org>
> > Sent: Sunday, March 30, 2003 1:04 PM
> > Subject: Re: HttpSessionBindingListener.valueUnbound() not called
> >
> >
> > Nope - with 4.1.24 I still get called for valueBound() but not
> > valueUnbound().
> >
> > Any other ideas?
> >
> >
> > code:
> >
> > public class FileList implements HttpSessionBindingListener {
> >     public void valueBound(HttpSessionBindingEvent event) {
> >         event.getSession().getServletContext().log( "bind" );
> >     }
> >
> >     public void valueUnbound(HttpSessionBindingEvent event) {
> >         // never logged
> >         event.getSession().getServletContext().log( "unbind" );
> >     }
> > }
> >
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Hans Bergsten" <ha...@gefionsoftware.com>
> > To: "Tomcat Developers List" <to...@jakarta.apache.org>
> > Sent: Saturday, March 29, 2003 2:19 PM
> > Subject: Re: HttpSessionBindingListener.valueUnbound() not called
> >
> >
> >
> >>David Thielen wrote:
> >>
> >>>Hi;
> >>>
> >>>I have an object that implements HttpSessionBindingListener. It calls
> >>>valueBound fine. But it never calls valueUnbound. Not when it times out
> >>
> > and
> >
> >>>not when Tomcat is closed. I am running 4.1.18.
> >>>
> >>>Any ideas?
> >>
> >>It works fine in TC 4.1.24, so you may want to upgrade.
> >>
> >>Hans
> >>--
> >>Hans Bergsten                                <ha...@gefionsoftware.com>
> >>Gefion Software                       <http://www.gefionsoftware.com/>
> >>Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
> >>Details at                                    <http://TheJSPBook.com/>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> >
>
>
> --
> Hans Bergsten                                <ha...@gefionsoftware.com>
> Gefion Software                       <http://www.gefionsoftware.com/>
> Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
> Details at                                    <http://TheJSPBook.com/>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>


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


Re: HttpSessionBindingListener.valueUnbound() not called

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
David Thielen wrote:
> One note to the below:
> 
> It does call it on a timeout under 4.1.24 (it did not do that in 4.1.18).
> But it does not call it if Tomcat is reloaded or exits - which according to
> the spec it is supposed to do.

Two things:
1) When you stop Tomcat, it saves all session data to disk; it does not
    terminate the sessions at this time, so don't expect a valueUnbound()
    call immediately at stop. When Tomcat is restarted, it loads all
    session data again and eventually calls valueUnbound() when it finds
    that the session has timed out. Also note that it only checks for
    timeouts every 1 second, so that's the shortest time-out value that
    is honored.
2) In order to save and reload the session data, all objects in the
    session must be serializable, e.g. implement java.io.Serializable.
    Your FileList class doesn't, so it can be saved and reloaded, hence
    the valueUnbound() method is never called after a restart.

Arguably, there's still a bug here. There's a comment in the Standard-
Session class for the method that saves the session data that any object
that is not serializable "will be unbound from the session, with
appropriate actions if it implements HttpSessionBindingListener," which
I assume mean valueUnbound() will be called. I don't see any signs of
this being done, however. You may want to file a bug report about this.

For a class that implements Serializable, however, everything seems to
work as it should in 4.1.24.

Hans

> ----- Original Message -----
> From: "David Thielen" <da...@thielen.com>
> To: ""Hans Bergsten"" <ha...@gefionsoftware.com>
> Cc: "Tomcat - dev" <to...@jakarta.apache.org>
> Sent: Sunday, March 30, 2003 1:04 PM
> Subject: Re: HttpSessionBindingListener.valueUnbound() not called
> 
> 
> Nope - with 4.1.24 I still get called for valueBound() but not
> valueUnbound().
> 
> Any other ideas?
> 
> 
> code:
> 
> public class FileList implements HttpSessionBindingListener {
>     public void valueBound(HttpSessionBindingEvent event) {
>         event.getSession().getServletContext().log( "bind" );
>     }
> 
>     public void valueUnbound(HttpSessionBindingEvent event) {
>         // never logged
>         event.getSession().getServletContext().log( "unbind" );
>     }
> }
> 
> 
> 
> 
> 
> ----- Original Message -----
> From: "Hans Bergsten" <ha...@gefionsoftware.com>
> To: "Tomcat Developers List" <to...@jakarta.apache.org>
> Sent: Saturday, March 29, 2003 2:19 PM
> Subject: Re: HttpSessionBindingListener.valueUnbound() not called
> 
> 
> 
>>David Thielen wrote:
>>
>>>Hi;
>>>
>>>I have an object that implements HttpSessionBindingListener. It calls
>>>valueBound fine. But it never calls valueUnbound. Not when it times out
>>
> and
> 
>>>not when Tomcat is closed. I am running 4.1.18.
>>>
>>>Any ideas?
>>
>>It works fine in TC 4.1.24, so you may want to upgrade.
>>
>>Hans
>>--
>>Hans Bergsten                                <ha...@gefionsoftware.com>
>>Gefion Software                       <http://www.gefionsoftware.com/>
>>Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
>>Details at                                    <http://TheJSPBook.com/>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 


-- 
Hans Bergsten                                <ha...@gefionsoftware.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>


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


Re: HttpSessionBindingListener.valueUnbound() not called

Posted by David Thielen <da...@thielen.com>.
One note to the below:

It does call it on a timeout under 4.1.24 (it did not do that in 4.1.18).
But it does not call it if Tomcat is reloaded or exits - which according to
the spec it is supposed to do.

thanks - dave


----- Original Message -----
From: "David Thielen" <da...@thielen.com>
To: ""Hans Bergsten"" <ha...@gefionsoftware.com>
Cc: "Tomcat - dev" <to...@jakarta.apache.org>
Sent: Sunday, March 30, 2003 1:04 PM
Subject: Re: HttpSessionBindingListener.valueUnbound() not called


Nope - with 4.1.24 I still get called for valueBound() but not
valueUnbound().

Any other ideas?


code:

public class FileList implements HttpSessionBindingListener {
    public void valueBound(HttpSessionBindingEvent event) {
        event.getSession().getServletContext().log( "bind" );
    }

    public void valueUnbound(HttpSessionBindingEvent event) {
        // never logged
        event.getSession().getServletContext().log( "unbind" );
    }
}





----- Original Message -----
From: "Hans Bergsten" <ha...@gefionsoftware.com>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Saturday, March 29, 2003 2:19 PM
Subject: Re: HttpSessionBindingListener.valueUnbound() not called


> David Thielen wrote:
> > Hi;
> >
> > I have an object that implements HttpSessionBindingListener. It calls
> > valueBound fine. But it never calls valueUnbound. Not when it times out
and
> > not when Tomcat is closed. I am running 4.1.18.
> >
> > Any ideas?
>
> It works fine in TC 4.1.24, so you may want to upgrade.
>
> Hans
> --
> Hans Bergsten                                <ha...@gefionsoftware.com>
> Gefion Software                       <http://www.gefionsoftware.com/>
> Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
> Details at                                    <http://TheJSPBook.com/>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>


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


Re: HttpSessionBindingListener.valueUnbound() not called

Posted by David Thielen <da...@thielen.com>.
Nope - with 4.1.24 I still get called for valueBound() but not valueUnbound().

Any other ideas?


code:

public class FileList implements HttpSessionBindingListener {
    public void valueBound(HttpSessionBindingEvent event) {
        event.getSession().getServletContext().log( "bind" );
    }
 
    public void valueUnbound(HttpSessionBindingEvent event) {
        // never logged
        event.getSession().getServletContext().log( "unbind" );
    }
}





----- Original Message ----- 
From: "Hans Bergsten" <ha...@gefionsoftware.com>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Saturday, March 29, 2003 2:19 PM
Subject: Re: HttpSessionBindingListener.valueUnbound() not called


> David Thielen wrote:
> > Hi;
> > 
> > I have an object that implements HttpSessionBindingListener. It calls
> > valueBound fine. But it never calls valueUnbound. Not when it times out and
> > not when Tomcat is closed. I am running 4.1.18.
> > 
> > Any ideas?
> 
> It works fine in TC 4.1.24, so you may want to upgrade.
> 
> Hans
> -- 
> Hans Bergsten                                <ha...@gefionsoftware.com>
> Gefion Software                       <http://www.gefionsoftware.com/>
> Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
> Details at                                    <http://TheJSPBook.com/>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 

Re: HttpSessionBindingListener.valueUnbound() not called

Posted by Hans Bergsten <ha...@gefionsoftware.com>.
David Thielen wrote:
> Hi;
> 
> I have an object that implements HttpSessionBindingListener. It calls
> valueBound fine. But it never calls valueUnbound. Not when it times out and
> not when Tomcat is closed. I am running 4.1.18.
> 
> Any ideas?

It works fine in TC 4.1.24, so you may want to upgrade.

Hans
-- 
Hans Bergsten                                <ha...@gefionsoftware.com>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 1.2 and JSTL 1.0
Details at                                    <http://TheJSPBook.com/>


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


HttpSessionBindingListener.valueUnbound() not called

Posted by David Thielen <da...@thielen.com>.
Hi;

I have an object that implements HttpSessionBindingListener. It calls
valueBound fine. But it never calls valueUnbound. Not when it times out and
not when Tomcat is closed. I am running 4.1.18.

Any ideas?

thanks - dave


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