Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RCP to RAP problem with Singleton
RCP to RAP problem with Singleton [message #530422] Thu, 29 April 2010 15:37 Go to next message
Dove  is currently offline Dove Friend
Messages: 2
Registered: April 2010
Junior Member
Hello, I would really appreciate help with problem I'm having.
I followed instructions for use singleton in RAP from http://wiki.eclipse.org/RAP/FAQ#What_is_a_Session_Singleton_ and_how_can_I_implement_one.3F
So my code from non-UI thread looks now:
final Display display = Display.getCurrent();
	public void run() {
		UICallBack.runNonUIThreadWithFakeContext( display, new Runnable() {
			
		      public void run() {
		    	  Session session = Session.getInstance();
		        // do something with the session singleton
		    	  
		  		// cekani na pripojeni
		  		while (!session.isConnected()) {

When i try to run it i am getting this message:
Exception in thread "Thread-8" java.lang.IllegalStateException: No context available outside of the request service lifecycle.
	at org.eclipse.rwt.internal.service.ContextProvider.getContext(ContextProvider.java:108)
	at org.eclipse.rwt.internal.service.ContextProvider.getStateInfo(ContextProvider.java:166)
	at org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSingletonBase.java:84)
	at chess.model.Session.getInstance(Session.java:61)
	at chess.parsers.GameParser.run(GameParser.java:44)
Exception in thread "Thread-6" java.lang.NullPointerException
	at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.getDisplayAdapter(UICallBackServiceHandler.java:549)
	at org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler.runNonUIThreadWithFakeContext(UICallBackServiceHandler.java:452)
	at org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeContext(UICallBack.java:44)
	at chess.parsers.SoughtParser.run(SoughtParser.java:44)


I cant find any help for the second exception. I would really appreciate help with this problem.
Thanks in Advance.


Problem solved. I was creating this non-UI thread from Activator. When i am creating this from Application then there is not this problem anymore.

[Updated on: Thu, 29 April 2010 17:06]

Report message to a moderator

Re: RCP to RAP problem with Singleton [message #530477 is a reply to message #530422] Thu, 29 April 2010 18:02 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
hm, the snippet looks OK so far and should work.
Can you ensure that Display.getCurrent() is actually executed on the
UI-Thread?
Can you extract a snippet from your application that runs standalone but
reproduces the problem?

HTH
Rüdiger
--
Rüdiger Herrmann
http://eclipsesource.com


On 29.04.2010 17:37, Dove wrote:
> Hello, I would really appreciate help with problem I'm having. I
> followed instructions for use singleton in RAP from
> http://wiki.eclipse.org/RAP/FAQ#What_is_a_Session_Singleton_ and_how_can_I_implement_one.3F
>
> So my code from non-UI class looks now:
> final Display display = Display.getCurrent();
> public void run() {
> UICallBack.runNonUIThreadWithFakeContext( display, new Runnable() {
>
> public void run() {
> Session session = Session.getInstance();
> // do something with the session singleton
> // cekani na pripojeni
> while (!session.isConnected()) {
> When i try to run it i am getting this message:
> Exception in thread "Thread-8" java.lang.IllegalStateException: No
> context available outside of the request service lifecycle.
> at
> org.eclipse.rwt.internal.service.ContextProvider.getContext( ContextProvider.java:108)
>
> at
> org.eclipse.rwt.internal.service.ContextProvider.getStateInf o(ContextProvider.java:166)
>
> at
> org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSing letonBase.java:84)
>
> at chess.model.Session.getInstance(Session.java:61)
> at chess.parsers.GameParser.run(GameParser.java:44)
> Exception in thread "Thread-6" java.lang.NullPointerException
> at
> org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler. getDisplayAdapter(UICallBackServiceHandler.java:549)
>
> at
> org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler. runNonUIThreadWithFakeContext(UICallBackServiceHandler.java: 452)
>
> at
> org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeC ontext(UICallBack.java:44)
>
> at chess.parsers.SoughtParser.run(SoughtParser.java:44)
>
> I cant find any help for the second exception. I would really appreciate
> help with this problem. Thanks in Advance.
Re: RCP to RAP problem with Singleton [message #530513 is a reply to message #530477] Thu, 29 April 2010 21:28 Go to previous message
Dove  is currently offline Dove Friend
Messages: 2
Registered: April 2010
Junior Member
Thank you for response!
Sorry I just edited my message. Yes problem was that Display.getCurrent() wasnt executed on the
UI-Thread. Thank you
Previous Topic:UploadWidget is not working with latest CVS
Next Topic:Key stroke detection
Goto Forum:
  


Current Time: Thu Apr 25 12:03:12 GMT 2024

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

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

Back to the top