Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Refreshing RWT standalone throws exception
Refreshing RWT standalone throws exception [message #908754] Thu, 06 September 2012 00:19 Go to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 101
Registered: February 2011
Senior Member
I've built a proof of concept rwt standalone single source app.

Every second time I restart the session by pressing F5 I get the following exception:
2012-09-06 12:11:37.909:WARN:oejs.ServletHandler:ERROR:  /ucv
java.lang.NullPointerException
	at org.eclipse.swt.widgets.Synchronizer.removeFirst(Synchronizer.java:145)
	at org.eclipse.swt.widgets.Synchronizer.releaseSynchronizer(Synchronizer.java:127)
	at org.eclipse.swt.widgets.Display.release(Display.java:688)
	at org.eclipse.swt.graphics.Device.dispose(Device.java:287)
	at org.eclipse.rap.rwt.internal.lifecycle.SimpleLifeCycle$SimpleSessionShutdownAdapter$1.run(SimpleLifeCycle.java:92)
	at org.eclipse.rap.rwt.internal.lifecycle.FakeContextUtil.runNonUIThreadWithFakeContext(FakeContextUtil.java:58)
	at org.eclipse.rap.rwt.internal.lifecycle.SimpleLifeCycle$SimpleSessionShutdownAdapter.interceptShutdown(SimpleLifeCycle.java:87)
	at org.eclipse.rap.rwt.internal.service.SessionStoreImpl.valueUnbound(SessionStoreImpl.java:182)
	at org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.clearSessionStore(LifeCycleServiceHandler.java:155)
	at org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.reinitializeSessionStore(LifeCycleServiceHandler.java:140)
	at org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.handlePostRequest(LifeCycleServiceHandler.java:88)
	at org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.synchronizedService(LifeCycleServiceHandler.java:67)
	at org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:58)
	at org.eclipse.rap.rwt.engine.RWTServlet.handleValidRequest(RWTServlet.java:101)
	at org.eclipse.rap.rwt.engine.RWTServlet.doPost(RWTServlet.java:80)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.rap.rwt.osgi.internal.CutOffContextPathWrapper.service(CutOffContextPathWrapper.java:106)
	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:384)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
	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:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:900)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:954)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Unknown Source)

The session starts correctly. The first restart (by pressing F5) throws the exception. Every second F5 from then on throws the same exception.
Any ideas? I'm using the nightly RAP 2.0 build 20120904-0111

The messageLock field in Synchronizer is null, which leads me to believe its releaseSynchronizer method is being called twice, but the only call I can find to that method is wraped in the if (!isDisposed) {... block in Device#dispose
Re: Refreshing RWT standalone throws exception [message #908770 is a reply to message #908754] Thu, 06 September 2012 01:13 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 101
Registered: February 2011
Senior Member
It looks like the problem is caused by adding a DisposeListener to a Shell that calls Display.dispose.

I did this so the RCP launch bundle can call the application startup method (which creates various shells during the login process) then just spin the event loop like so
	public Object start(IApplicationContext context) throws Exception {
... call startup method
		while (!display.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return EXIT_OK;
	}


While the RWT launch bundle EntryPoint simply calls the application startup method.
	public int createUI() {
...call startup method
	    return 0;
	}


I suppose I can pass a runnable to the startup method that gets call when the application should shut down. RWT impl can be empty and RCP impl can set a flag that is tested in the while() loop along with Display.isDisposed
Re: Refreshing RWT standalone throws exception [message #908888 is a reply to message #908770] Thu, 06 September 2012 07:16 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Hi Chris,
your application is running in SWT_COMPATIBILITY mode [1]. Isn't it? In
this case you need readAndDispatch loop in your entry point as well....
Or I didn't understand you correctly.

[1]
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.rap.help%2Fhelp%2Fhtml%2Freference%2Fapi%2Forg%2Feclipse%2Frwt%2Fapplication%2FApplication.OperationMode.html
Best,
Ivan


On 9/6/2012 4:13 AM, Chris Fairhall wrote:
> It looks like the problem is caused by adding a DisposeListener to a
> Shell that calls Display.dispose.
>
> I did this so the RCP launch bundle can call the application startup
> method (which creates various shells during the login process) then
> just spin the event loop like so
>
> public Object start(IApplicationContext context) throws Exception {
> .. call startup method
> while (!display.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> return EXIT_OK;
> }
>
>
> While the RWT launch bundle EntryPoint simply calls the application
> startup method.
>
> public int createUI() {
> ..call startup method
> return 0;
> }
>
>
> I suppose I can pass a runnable to the startup method that gets call
> when the application should shut down. RWT impl can be empty and RCP
> impl can set a flag that is tested in the while() loop along with
> Display.isDisposed

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Refreshing RWT standalone throws exception [message #909375 is a reply to message #908888] Fri, 07 September 2012 03:43 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 101
Registered: February 2011
Senior Member
No, When running as RWT it's running under JEE mode (hence the reference to SimpleLifeCycle in the stack trace). A requirement is session replication. I'm not actually using the Eclipse Workbench.
Re: Refreshing RWT standalone throws exception [message #909442 is a reply to message #909375] Fri, 07 September 2012 06:31 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Chris,
could you provide some code snippets to demonstrate (reproduce) the issue?
Best,
Ivan

On 9/7/2012 6:43 AM, Chris Fairhall wrote:
> No, When running as RWT it's running under JEE mode (hence the
> reference to SimpleLifeCycle in the stack trace). A requirement is
> session replication. I'm not actually using the Eclipse Workbench.

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Refreshing RWT standalone throws exception [message #910524 is a reply to message #909442] Sun, 09 September 2012 23:09 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 101
Registered: February 2011
Senior Member
Attached is an example project to replicate the issue.

Here is the code:
public class EntryPoint implements IEntryPoint {
	@Override
	public int createUI() {
		Shell shell = new Shell();
		shell.addDisposeListener(new DisposeListener() {
			@Override
			public void widgetDisposed(DisposeEvent event) {
				Display.getCurrent().dispose();
			}
		});
		shell.setSize(200, 200);
		shell.setVisible(true);

	    return 0;
	}
}


Pressing F5 throws an exception every second time.
  • Attachment: rwttest.zip
    (Size: 4.72KB, Downloaded 80 times)
Re: Refreshing RWT standalone throws exception [message #911766 is a reply to message #910524] Wed, 12 September 2012 09:22 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1291
Registered: July 2009
Senior Member

Chris,

You should not call Display#dispose() in a dispose listener (actually,
you should not call this method at all in RAP). Here's what happens:

- Browser refresh leads to a disposal of the display
- In Display#dispose(), all Shells are disposed of
- Your dispose listener is notified which calls display dispose
-> Display#dispose() is called during Display#dispose() ⚡

The same code leads to a "widget is disposed" exception in SWT. When you
add a button to your snippet that disposes of the display, you'll see
this exception. I've opened a bug [1] to throw the appropriate SWT
exception in RAP as well.

What is the display.dispose() call supposed to achieve in your application?

Regards,
Ralf

[1] 389384: Calling Display#dispose() during disposal of the display
should throw SWT exception
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389384

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Refreshing RWT standalone throws exception [message #912037 is a reply to message #911766] Wed, 12 September 2012 20:44 Go to previous message
Chris Fairhall is currently offline Chris Fairhall
Messages: 101
Registered: February 2011
Senior Member
You're right, I shouldn't have called dispose in a dispose listener.
It was supposed to ensure the event loop that the RCP version has doesn't continue running. I have since implemented another method of doing this.
Previous Topic:RAP and MSSQL
Next Topic:Virtual tree viewer reinserts orphaned items
Goto Forum:
  


Current Time: Thu Oct 30 17:34:28 GMT 2014

Powered by FUDForum. Page generated in 0.01877 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software