Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354368 - Occasional exception on refresh (F5)
Summary: Occasional exception on refresh (F5)
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.5   Edit
Hardware: PC Linux
: P1 normal (vote)
Target Milestone: 1.5 M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 368224 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-08-10 08:16 EDT by Ralf Sternberg CLA
Modified: 2012-02-24 06:41 EST (History)
3 users (show)

See Also:


Attachments
Test case (2.77 KB, patch)
2011-10-08 13:23 EDT, Rüdiger Herrmann CLA
no flags Details | Diff
Entry point to reproduce the issue with RAP 1.5 (1.12 KB, text/plain)
2012-02-20 14:36 EST, Ivan Furnadjiev CLA
no flags Details
Proposed patch (2.54 KB, patch)
2012-02-21 07:06 EST, Ivan Furnadjiev CLA
no flags Details | Diff
Proposed patch (2.54 KB, patch)
2012-02-21 07:23 EST, Ivan Furnadjiev CLA
no flags Details | Diff
Proposed patch (5.63 KB, patch)
2012-02-21 10:04 EST, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Sternberg CLA 2011-08-10 08:16:05 EDT
This seems to happen very rarely when refreshing the page with F5. Frank has noticed it once some weeks ago, I got it only once yet.
In my case, the browser was Chromium/Linux.

java.lang.IllegalStateException: SingletonManager already installed
for session: 16hhf4n4i7a5q1inizl1jzpees
       at org.eclipse.rwt.internal.SingletonManager.checkNotInstalled(SingletonManager.java:70)
       at org.eclipse.rwt.internal.SingletonManager.install(SingletonManager.java:27)
       at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.clearSessionStore(LifeCycleServiceHandler.java:139)
       at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.checkRequest(LifeCycleServiceHandler.java:126)
       at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.runLifeCycle(LifeCycleServiceHandler.java:72)
       at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.synchronizedService(LifeCycleServiceHandler.java:55)
       at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:45)
       at org.eclipse.rwt.internal.service.ServiceManager$HandlerDispatcher.service(ServiceManager.java:34)
       at org.eclipse.rwt.internal.engine.RWTDelegate.handleValidRequest(RWTDelegate.java:62)
       at org.eclipse.rwt.internal.engine.RWTDelegate.doPost(RWTDelegate.java:41)
       at org.eclipse.rwt.internal.engine.RWTDelegate.doGet(RWTDelegate.java:33)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
       at org.eclipse.rap.rwt.osgi.internal.CutOffContextPathWrapper.service(CutOffContextPathWrapper.java:103)
       at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
       at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
       at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
       at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:317)
       at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
       at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
       at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
       at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
       at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
       at org.mortbay.jetty.Server.handle(Server.java:326)
       at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
       at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:924)
       at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
       at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
       at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
       at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
       at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Comment 1 Ivan Furnadjiev CLA 2011-08-10 08:51:56 EDT
The exception is the same like in bug 340742 comment #6. To reproduce it 100%:
1. Start Workbench Demo
2. Choose File -> Exit.
3. Refresh with F5.
Comment 2 Rüdiger Herrmann CLA 2011-10-08 09:16:29 EDT
I see the exception when running RWT standalone along with requests for non-existing resources
Jetty prints a message like WARN::/rwt-resources/themes/images/ec0d88bb followed by the exception
It is not yet clear to me why the resources cannot be found but it seems that the resource requests (incompletely) clear the session.
Comment 3 Rüdiger Herrmann CLA 2011-10-08 13:23:02 EDT
Created attachment 204804 [details]
Test case

I think the source of the problem is that LifeCycleServiceHandler#clearSessionStore() is unsynchronized. At least I have a failing test case and synchronizing the method lets the test succeed.
I observed not only the mentioned exception but a number of different exceptions in different places.
Comment 4 Rüdiger Herrmann CLA 2011-10-08 16:46:18 EDT
Please disregard comment #3, totally wrong. LifeCycleServiceHandler#clearSessionStore() *is* synchronized as there is a sync-lock around the whole service() method.
Comment 5 Holger Staudacher CLA 2012-01-27 10:22:14 EST
*** Bug 368224 has been marked as a duplicate of this bug. ***
Comment 6 Holger Staudacher CLA 2012-01-27 10:24:13 EST
We ran into this bug also with Android client.

Here is the StackTrace:


osgi> 2012-01-26 15:05:52.079:WARN:oejs.ServletHandler:ERROR:  /randy
java.lang.IllegalStateException: SingletonManager already installed for session: 1d6oe6qhneol41saskicqca6ga
 at org.eclipse.rwt.internal.SingletonManager.checkNotInstalled(SingletonManager.java:70)
 at org.eclipse.rwt.internal.SingletonManager.install(SingletonManager.java:27)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.clearSessionStore(LifeCycleServiceHandler.java:139)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.checkRequest(LifeCycleServiceHandler.java:126)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.runLifeCycle(LifeCycleServiceHandler.java:76)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.synchronizedService(LifeCycleServiceHandler.java:59)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:49)
 at org.eclipse.rwt.internal.service.ServiceManager$HandlerDispatcher.service(ServiceManager.java:34)
 at org.eclipse.rwt.engine.RWTServlet.handleValidRequest(RWTServlet.java:68)
 at org.eclipse.rwt.engine.RWTServlet.doPost(RWTServlet.java:47)
 at org.eclipse.rwt.engine.RWTServlet.doGet(RWTServlet.java:39)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.rap.rwt.osgi.internal.CutOffContextPathWrapper.service(CutOffContextPathWrapper.java:105)
 at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:323)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:575)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:485)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1061)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:995)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
 at org.eclipse.jetty.server.Server.handle(Server.java:350)
 at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:431)
 at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:896)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:647)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:233)
 at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:68)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
 at java.lang.Thread.run(Thread.java:662)
2012-01-26 15:05:53.124:WARN:oejs.ServletHandler:ERROR:  /randy
java.lang.IllegalStateException: SingletonManager already installed for session: 1d6oe6qhneol41saskicqca6ga
 at org.eclipse.rwt.internal.SingletonManager.checkNotInstalled(SingletonManager.java:70)
 at org.eclipse.rwt.internal.SingletonManager.install(SingletonManager.java:27)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.clearSessionStore(LifeCycleServiceHandler.java:139)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.checkRequest(LifeCycleServiceHandler.java:126)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.runLifeCycle(LifeCycleServiceHandler.java:76)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.synchronizedService(LifeCycleServiceHandler.java:59)
 at org.eclipse.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:49)
 at org.eclipse.rwt.internal.service.ServiceManager$HandlerDispatcher.service(ServiceManager.java:34)
 at org.eclipse.rwt.engine.RWTServlet.handleValidRequest(RWTServlet.java:68)
 at org.eclipse.rwt.engine.RWTServlet.doPost(RWTServlet.java:47)
 at org.eclipse.rwt.engine.RWTServlet.doGet(RWTServlet.java:39)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.rap.rwt.osgi.internal.CutOffContextPathWrapper.service(CutOffContextPathWrapper.java:105)
 at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:323)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:575)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:485)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1061)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:995)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
 at org.eclipse.jetty.server.Server.handle(Server.java:350)
 at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:431)
 at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:896)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:647)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:233)
 at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:68)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
 at java.lang.Thread.run(Thread.java:662)
Comment 7 Ivan Furnadjiev CLA 2012-02-20 14:36:23 EST
Created attachment 211281 [details]
Entry point to reproduce the issue with RAP 1.5

Finally, I've managed to trace down the problem. Here is an entry point to reproduce the issue:
1. Start the entry point as RAP application.
2. Close the shell - click on the shell "X" button.
3. Press browser F5 to restart the session.
Comment 8 Ivan Furnadjiev CLA 2012-02-21 03:14:33 EST
Another way to reproduce it:
1. Start the Workbench Demo
2. Close the main shell – click on the shell "X" button.
3. Press CTRL+S (this is a know key binding for editor save)
4. Press browser F5 to restart the session.

In both cases there is a request sent after the server-side main shell is disposed (main read & dispatch loop has been left and display.sleep() is not called anymore). This request wakeup the UIThread, which is currently waiting for session timeout to die (UIThreadTerminatedError) and to clear the session store. As a result - the session store is not cleared.
Comment 9 Ivan Furnadjiev CLA 2012-02-21 07:06:06 EST
Created attachment 211324 [details]
Proposed patch

This patch prevents the UI thread from waking up if it is waiting to die.
Comment 10 Ivan Furnadjiev CLA 2012-02-21 07:23:23 EST
Created attachment 211325 [details]
Proposed patch

This is the previous patch with fixed typo in the constant name.
Comment 11 Ivan Furnadjiev CLA 2012-02-21 10:04:49 EST
Created attachment 211333 [details]
Proposed patch

JUnit test has been added to the previous patch.
Comment 12 Ivan Furnadjiev CLA 2012-02-24 06:41:18 EST
Applied last patch to CVS HEAD with minor constant name change.