0

Session.invalidate() raises an IllegalStateException under Jetty

asked 2008-09-02 08:34:01 +0800

cvarona gravatar image cvarona
554 1 6

As a naïve approach to logout I've tried to just invalidate the current http session:

<button label='Logout' onClick='session.invalidate()' />

This seemingly innocent button causes however an IllegalStateException to be raised:

GRAVE: Failed to cleanup session
java.lang.IllegalStateException
at org.mortbay.jetty.servlet.AbstractSessionManager$Session.getAttribute(AbstractSessionManager.java:784)
at org.zkoss.zk.ui.http.SimpleSession.getAttribute(SimpleSession.java:205)
at org.zkoss.zk.ui.http.SimpleSession.cleanSessAttrs(SimpleSession.java:178)
at org.zkoss.zk.ui.http.SimpleSession.onDestroyed(SimpleSession.java:348)
at org.zkoss.zk.ui.http.WebManager.onSessionDestroyed(WebManager.java:302)
at org.zkoss.zk.ui.http.HttpSessionListener.sessionDestroyed(HttpSessionListener.java:33)
at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession(AbstractSessionManager.java:665)
at org.mortbay.jetty.servlet.AbstractSessionManager$Session.invalidate(AbstractSessionManager.java:938)
at org.mortbay.jetty.servlet.HashSessionManager$Session.invalidate(HashSessionManager.java:500)
at org.zkoss.zk.ui.http.SimpleSession.invalidateNow(SimpleSession.java:286)
at org.zkoss.zk.ui.impl.UiEngineImpl.doDeactivate(UiEngineImpl.java:1319)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:874)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:410)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:296)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:305)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
...
2008-09-02 10:25:38.278::WARN: /backbone/zkau
java.lang.IllegalStateException
at org.mortbay.jetty.servlet.AbstractSessionManager$Session.removeAttribute(AbstractSessionManager.java:1016)
at org.zkoss.zk.ui.http.SimpleSessionCache.remove(SimpleSessionCache.java:54)
at org.zkoss.zk.ui.http.WebManager.onSessionDestroyed(WebManager.java:306)
at org.zkoss.zk.ui.http.HttpSessionListener.sessionDestroyed(HttpSessionListener.java:33)
at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession(AbstractSessionManager.java:665)
at org.mortbay.jetty.servlet.AbstractSessionManager$Session.invalidate(AbstractSessionManager.java:938)
at org.mortbay.jetty.servlet.HashSessionManager$Session.invalidate(HashSessionManager.java:500)
at org.zkoss.zk.ui.http.SimpleSession.invalidateNow(SimpleSession.java:286)
at org.zkoss.zk.ui.impl.UiEngineImpl.doDeactivate(UiEngineImpl.java:1319)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:874)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:410)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:296)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:305)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

The underlying reason seems to be that the onDestroyed() event reaches the zk session object after the native session has been invalidated; when it proceeds to clean up the session attributes like this:

private final void cleanSessAttrs() {
final Object names = getAttribute(ATTR_PRIVATE);
if (names instanceof Set) { //Bug 1954655: bakward-compatible
for (Iterator it = ((Set)names).iterator(); it.hasNext();)
rmAttr((String)it.next());
}
rmAttr(ATTR_PRIVATE);
}

it's already illegal to try to retrieve any attribute from the session (and of no much use if we are to believe the servlet documentation, for the javadoc for HttpSession states clearly

invalidate

void invalidate()

Invalidates this session then unbinds any objects bound to it.

Is there anyway to circumvent this problem?

With kind regards

C. Varona

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2008-09-04 07:15:39 +0800

tomyeh gravatar image tomyeh
610 1 3
http://blog.zkoss.org ZK Team

updated 2008-09-04 07:17:43 +0800

After digging a bit, it seems Jetty calls HttpSessionListener.sessionDestroyed twice in this case.
We'll try to work around this. Please follow http://sourceforge.net/tracker/index.php?func=detail&aid=2092632&group_id=152762&atid=785191

The stack trace we found is as follows.
INFO | jvm 1 | 2008/09/04 12:34:26 | java.lang.Exception: Stack trace
INFO | jvm 1 | 2008/09/04 12:34:26 | at java.lang.Thread.dumpStack(Unknown Source)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.WebManager.onSessionDestroyed(WebManager.java:295)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.HttpSessionListener.sessionDestroyed(HttpSessionListener.java:33)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession(AbstractSessionManager.java:665)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.AbstractSessionManager$Session.invalidate(AbstractSessionManager.java:938)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.HashSessionManager$Session.invalidate(HashSessionManager.java:500)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.SimpleSession.invalidateNow(SimpleSession.java:286)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.doDeactivate(UiEngineImpl.java:1513)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1066)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:484)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:372)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:381)
INFO | jvm 1 | 2008/09/04 12:34:26 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
INFO | jvm 1 | 2008/09/04 12:34:26 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.Server.handle(Server.java:324)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

INFO | jvm 1 | 2008/09/04 12:34:26 | java.lang.Exception: Stack trace
INFO | jvm 1 | 2008/09/04 12:34:26 | at java.lang.Thread.dumpStack(Unknown Source)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.WebManager.onSessionDestroyed(WebManager.java:295)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.HttpSessionListener.sessionDestroyed(HttpSessionListener.java:33)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession(AbstractSessionManager.java:665)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.AbstractSessionManager$Session.invalidate(AbstractSessionManager.java:938)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.HashSessionManager$Session.invalidate(HashSessionManager.java:500)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.SimpleSession.invalidateNow(SimpleSession.java:286)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.doDeactivate(UiEngineImpl.java:1513)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.deactivate(UiEngineImpl.java:1430)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.desktopDestroyed(UiEngineImpl.java:184)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.SimpleDesktopCache.desktopDestroyed(SimpleDesktopCache.java:105)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.SimpleDesktopCache.stop(SimpleDesktopCache.java:141)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.SessionDesktopCacheProvider.sessionDestroyed(SessionDesktopCacheProvider.java:59)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.WebManager.onSessionDestroyed(WebManager.java:304)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.HttpSessionListener.sessionDestroyed(HttpSessionListener.java:33)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession(AbstractSessionManager.java:665)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.AbstractSessionManager$Session.invalidate(AbstractSessionManager.java:938)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.HashSessionManager$Session.invalidate(HashSessionManager.java:500)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.http.SimpleSession.invalidateNow(SimpleSession.java:286)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.doDeactivate(UiEngineImpl.java:1513)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1066)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:484)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:372)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:381)
INFO | jvm 1 | 2008/09/04 12:34:26 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
INFO | jvm 1 | 2008/09/04 12:34:26 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.Server.handle(Server.java:324)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
INFO | jvm 1 | 2008/09/04 12:34:26 | at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

link publish delete flag offensive edit

answered 2008-09-02 09:18:29 +0800

cvarona gravatar image cvarona
554 1 6

I'm using zk 3.0.7 and jetty 6.1.11.

With kind regards

C. Varona

link publish delete flag offensive edit

answered 2008-09-02 08:59:13 +0800

sousa1981 gravatar image sousa1981
573 4

+1

I see it yesterday, I didn't have time to check it in more details.

It look like an modification in freshly version produced this bug.

What is your ZK version?

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-09-02 08:34:01 +0800

Seen: 727 times

Last updated: Sep 04 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More