You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Blair Cooper <bc...@rim.com> on 2006/01/31 20:36:27 UTC
Session.getId() throws IllegalStateException
The following code generates an exception when getId() is called with
Tomcat 5.5.15. In 5.5.7 it returned the session id.
I realize that the session is being invalidated, thus valueUnbound()
being
called. I also realize that the servlet spec/errata says that this
exception should be thrown when the session is invalid. I would contend
that; at the time valueUnbound() is called the session should still be
considered valid.
In our code we need to know which session is being invalidated in order
to
do some cleanup. Any chance that Tomcat would be changed/fixed to not
mark
the session as invalid until it has finished notifying the
HttpSessionBindingListeners?
Thanks,
Blair Cooper
public void valueUnbound(HttpSessionBindingEvent event)
{
String sessId = event.getSession().getId();
}
java.lang.IllegalStateException: getId: Session already invalidated
at
org.apache.catalina.session.StandardSession.getId(StandardSession.java:3
28)
at
org.apache.catalina.session.StandardSessionFacade.getId(StandardSessionF
acade.java:78)
at
com.teamon.util.system.SessionList.valueUnbound(SessionList.java:99)
at
org.apache.catalina.session.StandardSession.removeAttributeInternal(Stan
dardSession.java:1607)
at
org.apache.catalina.session.StandardSession.expire(StandardSession.java:
737)
at
org.apache.catalina.session.StandardSession.isValid(StandardSession.java
:577)
at
org.apache.catalina.session.ManagerBase.processExpires(ManagerBase.java:
678)
at
org.apache.catalina.session.ManagerBase.backgroundProcess(ManagerBase.ja
va:663)
at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.j
ava:1283)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.proc
essChildren(ContainerBase.java:1568)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.proc
essChildren(ContainerBase.java:1577)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.proc
essChildren(ContainerBase.java:1577)
at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(
ContainerBase.java:1557)
at java.lang.Thread.run(Unknown Source)
---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.
Re: Session.getId() throws IllegalStateException
Posted by Remy Maucherat <re...@gmail.com>.
On 1/31/06, Blair Cooper <bc...@rim.com> wrote:
> The following code generates an exception when getId() is called with
> Tomcat 5.5.15. In 5.5.7 it returned the session id.
>
> I realize that the session is being invalidated, thus valueUnbound()
> being
> called. I also realize that the servlet spec/errata says that this
> exception should be thrown when the session is invalid. I would contend
> that; at the time valueUnbound() is called the session should still be
> considered valid.
valueUnbond is called after the session has been invalidated.
> In our code we need to know which session is being invalidated in order
> to
> do some cleanup. Any chance that Tomcat would be changed/fixed to not
> mark
> the session as invalid until it has finished notifying the
> HttpSessionBindingListeners?
No (it was the same timing before, but Session.getId didn't throw an
exception), but I agree the change was a very bad decision. Hacking
Tomcat to remove the if (valid) is Session.getId is the way to go.
Other workaround: get the session id in valueBound and store it in a
field of your object.
--
xxxxxxxxxxxxxxxxxxxxxxxxx
Rémy Maucherat
Developer & Consultant
JBoss Group (Europe) SàRL
xxxxxxxxxxxxxxxxxxxxxxxxx
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org