Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » SWTException: Invalid thread access on multiple app-starts
SWTException: Invalid thread access on multiple app-starts [message #106768] Mon, 29 September 2008 12:37 Go to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Hi,

Till yesterdays my RAP-app runs very well.
But today i tested to access it from different computers.

I have a tree which contents in filled by reading some data from another
server.
By clicking on one item a new Tabitem will be created in a Tabfolder.

But whem in try this on the second computer i get an "SWTException:
Invalid thread access".

I think it is Session-problem. But i don't know how to handle with sessions.

Can any body help me???
Roland

(forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #106783 is a reply to message #106768] Mon, 29 September 2008 12:53 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi Roland,

without any source code its hard to say what's going wrong there... Do
you use asynchronous background threads? Can you post a
snippet/stacktrace or sth. like that?

Regards,
Stefan.

Roland Siebert schrieb:
> Hi,
>
> Till yesterdays my RAP-app runs very well.
> But today i tested to access it from different computers.
>
> I have a tree which contents in filled by reading some data from another
> server.
> By clicking on one item a new Tabitem will be created in a Tabfolder.
>
> But whem in try this on the second computer i get an "SWTException:
> Invalid thread access".
>
> I think it is Session-problem. But i don't know how to handle with
> sessions.
>
> Can any body help me???
> Roland
>
> (forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #106797 is a reply to message #106783] Mon, 29 September 2008 14:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benjamin.wolff.web.de

Hi,


just an idea, are you using static objects?? it's important to notice that static
declared objects are the same in every session when working with multiusers.
accessing from different workstation can cause this invalid thread access.

hth
-ben


Stefan Roeck schrieb:
> Hi Roland,
>
> without any source code its hard to say what's going wrong there... Do
> you use asynchronous background threads? Can you post a
> snippet/stacktrace or sth. like that?
>
> Regards,
> Stefan.
>
> Roland Siebert schrieb:
>> Hi,
>>
>> Till yesterdays my RAP-app runs very well.
>> But today i tested to access it from different computers.
>>
>> I have a tree which contents in filled by reading some data from
>> another server.
>> By clicking on one item a new Tabitem will be created in a Tabfolder.
>>
>> But whem in try this on the second computer i get an "SWTException:
>> Invalid thread access".
>>
>> I think it is Session-problem. But i don't know how to handle with
>> sessions.
>>
>> Can any body help me???
>> Roland
>>
>> (forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #106811 is a reply to message #106783] Mon, 29 September 2008 14:30 Go to previous messageGo to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Stefan Roeck schrieb:
> Do you use asynchronous background threads?

I don't think so. I'm not very familiar with threads.

> Can you post a snippet/stacktrace or sth. like that?

hmm. Thats is a to much to post.
But I have debug it and while it, i see that "Thread.currentThread()"
and "getDisplay().getThread()" are different.

org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:1757)
at org.eclipse.swt.SWT.error(SWT.java:1677)
at org.eclipse.swt.SWT.error(SWT.java:1648)
at org.eclipse.swt.widgets.Widget.error(Widget.java:775)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:718)
at org.eclipse.swt.custom.CTabFolder.getItems(CTabFolder.java:2 11)
at
com.test.rap.monitor.views.composite.Content.findTabItem(Con tent.java:207)
at com.test.rap.monitor.views.composite.Content.createTab(Conte nt.java:116)
at
com.test.rap.monitor.views.composite.Navigation$4.selectionC hanged(Navigation.java:138)
at org.eclipse.jface.viewers.Viewer$1.run(Viewer.java:169)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:47)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer .java:167)
at
org.eclipse.jface.viewers.StructuredViewer.updateSelection(S tructuredViewer.java:2060)
at
org.eclipse.jface.viewers.StructuredViewer.handleSelect(Stru cturedViewer.java:1136)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected( StructuredViewer.java:1166)
at
org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenS trategy.java:223)
at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.ja va:217)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:394)
at
org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatc hEvent(UntypedEventAdapter.java:313)
at
org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetS elected(UntypedEventAdapter.java:80)
at
org.eclipse.swt.events.SelectionEvent.dispatchToObserver(Sel ectionEvent.java:174)
at org.eclipse.rwt.internal.events.Event.processEvent(Event.jav a:44)
at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.ja va:114)
at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.jav a:154)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.readAndDispa tch(RWTLifeCycle.java:241)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :682)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2388)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2347)
at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:22 00)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:425)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:408)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:157)
at com.test.rap.monitor.Application.createUI(Application.java:1 3)
at
org.eclipse.rwt.internal.lifecycle.EntryPointManager.createU I(EntryPointManager.java:92)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWT LifeCycle.java:228)
at
org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont roller.run(RWTLifeCycle.java:116)
at java.lang.Thread.run(Thread.java:613)
Re: SWTException: Invalid thread access on multiple app-starts [message #106862 is a reply to message #106783] Mon, 29 September 2008 15:24 Go to previous messageGo to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Me again.

I think i found my fault.

I'm using this class to get access to some data in diffenrent classes.
But in each session it is the same instance.
I'm right???

How can i fix this?

public class Registry {

protected static Map<String, Object> map = new HashMap<String, Object>();

public static <X> X get(String id) {
return (X) map.get(id);
}

public static Map<String, Object> getAll() {
return map;
}


public static void register(String id, Object obj) {
map.put(id, obj);
}

public static void unregister(String id) {
map.remove(id);
}

public static void unregisterAll() {
map.clear();
}

private Registry() {
}
}



Stefan Roeck schrieb:
> Hi Roland,
>
> without any source code its hard to say what's going wrong there... Do
> you use asynchronous background threads? Can you post a
> snippet/stacktrace or sth. like that?
>
> Regards,
> Stefan.
>
> Roland Siebert schrieb:
>> Hi,
>>
>> Till yesterdays my RAP-app runs very well.
>> But today i tested to access it from different computers.
>>
>> I have a tree which contents in filled by reading some data from
>> another server.
>> By clicking on one item a new Tabitem will be created in a Tabfolder.
>>
>> But whem in try this on the second computer i get an "SWTException:
>> Invalid thread access".
>>
>> I think it is Session-problem. But i don't know how to handle with
>> sessions.
>>
>> Can any body help me???
>> Roland
>>
>> (forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #106902 is a reply to message #106862] Mon, 29 September 2008 17:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benjamin.wolff.web.de

hi,

take a look at the SessionSingletonBase Class. If you extend your 'container'
from this object and use the static methods to get an object, it will return an
object that is unique for each session. the documentation should explain the way
is works.

hth
-ben



Roland Siebert schrieb:
> Me again.
>
> I think i found my fault.
>
> I'm using this class to get access to some data in diffenrent classes.
> But in each session it is the same instance.
> I'm right???
>
> How can i fix this?
>
> public class Registry {
>
> protected static Map<String, Object> map = new HashMap<String,
> Object>();
>
> public static <X> X get(String id) {
> return (X) map.get(id);
> }
>
> public static Map<String, Object> getAll() {
> return map;
> }
>
>
> public static void register(String id, Object obj) {
> map.put(id, obj);
> }
>
> public static void unregister(String id) {
> map.remove(id);
> }
>
> public static void unregisterAll() {
> map.clear();
> }
>
> private Registry() {
> }
> }
>
>
>
> Stefan Roeck schrieb:
>> Hi Roland,
>>
>> without any source code its hard to say what's going wrong there... Do
>> you use asynchronous background threads? Can you post a
>> snippet/stacktrace or sth. like that?
>>
>> Regards,
>> Stefan.
>>
>> Roland Siebert schrieb:
>>> Hi,
>>>
>>> Till yesterdays my RAP-app runs very well.
>>> But today i tested to access it from different computers.
>>>
>>> I have a tree which contents in filled by reading some data from
>>> another server.
>>> By clicking on one item a new Tabitem will be created in a Tabfolder.
>>>
>>> But whem in try this on the second computer i get an "SWTException:
>>> Invalid thread access".
>>>
>>> I think it is Session-problem. But i don't know how to handle with
>>> sessions.
>>>
>>> Can any body help me???
>>> Roland
>>>
>>> (forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #107022 is a reply to message #106902] Tue, 30 September 2008 10:50 Go to previous messageGo to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Hi,

thanks.
But how do I use this when a class already extends another class???

Like this class:

import org.eclipse.swt.widgets.Composite;

public abstract class MyComposite extends Composite{

protected MyComposite(Composite parent, int style) {
super(parent, style);
createLayout();
init();
}

protected abstract void createLayout();

protected abstract void init();
}

Roland

Ben W. schrieb:
> hi,
>
> take a look at the SessionSingletonBase Class. If you extend your
> 'container' from this object and use the static methods to get an
> object, it will return an object that is unique for each session. the
> documentation should explain the way is works.
>
> hth
> -ben
>
>
>
> Roland Siebert schrieb:
>> Me again.
>>
>> I think i found my fault.
>>
>> I'm using this class to get access to some data in diffenrent classes.
>> But in each session it is the same instance.
>> I'm right???
>>
>> How can i fix this?
>>
>> public class Registry {
>>
>> protected static Map<String, Object> map = new HashMap<String,
>> Object>();
>>
>> public static <X> X get(String id) {
>> return (X) map.get(id);
>> }
>>
>> public static Map<String, Object> getAll() {
>> return map;
>> }
>>
>> public static void register(String id, Object obj) {
>> map.put(id, obj);
>> }
>>
>> public static void unregister(String id) {
>> map.remove(id);
>> }
>>
>> public static void unregisterAll() {
>> map.clear();
>> }
>>
>> private Registry() {
>> }
>> }
>>
>>
>>
>> Stefan Roeck schrieb:
>>> Hi Roland,
>>>
>>> without any source code its hard to say what's going wrong there...
>>> Do you use asynchronous background threads? Can you post a
>>> snippet/stacktrace or sth. like that?
>>>
>>> Regards,
>>> Stefan.
>>>
>>> Roland Siebert schrieb:
>>>> Hi,
>>>>
>>>> Till yesterdays my RAP-app runs very well.
>>>> But today i tested to access it from different computers.
>>>>
>>>> I have a tree which contents in filled by reading some data from
>>>> another server.
>>>> By clicking on one item a new Tabitem will be created in a Tabfolder.
>>>>
>>>> But whem in try this on the second computer i get an "SWTException:
>>>> Invalid thread access".
>>>>
>>>> I think it is Session-problem. But i don't know how to handle with
>>>> sessions.
>>>>
>>>> Can any body help me???
>>>> Roland
>>>>
>>>> (forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #107044 is a reply to message #107022] Tue, 30 September 2008 11:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Roland,

please don't 'flood' the newsgroup with the ever same question.
Chances degrade that your post will be answered at all;)

If the MyComposite is the *actual* use-case for
SessionSingletonBase, then just don't make it a session-singleton.
Each widget has session scope since it directly or indirectly
belongs to a Display, which in turn exists only once per session.

In case the code snippet stands only as an example:
Undoubtedly, the support for session-singletons as it is currently
implemented is less-than-ideal. To work around this you could
delegate to an inner class that extends SessionSingletonBase and
holds all session-scoped information. There are certainly many more
ways to work around this. Try to search for "java extend two
classes" or similar and you will certainly find an answer that suits
your needs.

HTH
Rüdiger


Siebert wrote:
> Hi,
>
> thanks.
> But how do I use this when a class already extends another class???
>
> Like this class:
>
> import org.eclipse.swt.widgets.Composite;
>
> public abstract class MyComposite extends Composite{
>
> protected MyComposite(Composite parent, int style) {
> super(parent, style);
> createLayout();
> init();
> }
>
> protected abstract void createLayout();
>
> protected abstract void init();
> }
>
> Roland
>
> Ben W. schrieb:
>> hi,
>>
>> take a look at the SessionSingletonBase Class. If you extend your
>> 'container' from this object and use the static methods to get an
>> object, it will return an object that is unique for each session. the
>> documentation should explain the way is works.
>>
>> hth
>> -ben
>>
>>
>>
>> Roland Siebert schrieb:
>>> Me again.
>>>
>>> I think i found my fault.
>>>
>>> I'm using this class to get access to some data in diffenrent classes.
>>> But in each session it is the same instance.
>>> I'm right???
>>>
>>> How can i fix this?
>>>
>>> public class Registry {
>>>
>>> protected static Map<String, Object> map = new HashMap<String,
>>> Object>();
>>>
>>> public static <X> X get(String id) {
>>> return (X) map.get(id);
>>> }
>>>
>>> public static Map<String, Object> getAll() {
>>> return map;
>>> }
>>>
>>> public static void register(String id, Object obj) {
>>> map.put(id, obj);
>>> }
>>>
>>> public static void unregister(String id) {
>>> map.remove(id);
>>> }
>>>
>>> public static void unregisterAll() {
>>> map.clear();
>>> }
>>>
>>> private Registry() {
>>> }
>>> }
>>>
>>>
>>>
>>> Stefan Roeck schrieb:
>>>> Hi Roland,
>>>>
>>>> without any source code its hard to say what's going wrong there...
>>>> Do you use asynchronous background threads? Can you post a
>>>> snippet/stacktrace or sth. like that?
>>>>
>>>> Regards,
>>>> Stefan.
>>>>
>>>> Roland Siebert schrieb:
>>>>> Hi,
>>>>>
>>>>> Till yesterdays my RAP-app runs very well.
>>>>> But today i tested to access it from different computers.
>>>>>
>>>>> I have a tree which contents in filled by reading some data from
>>>>> another server.
>>>>> By clicking on one item a new Tabitem will be created in a Tabfolder.
>>>>>
>>>>> But whem in try this on the second computer i get an "SWTException:
>>>>> Invalid thread access".
>>>>>
>>>>> I think it is Session-problem. But i don't know how to handle with
>>>>> sessions.
>>>>>
>>>>> Can any body help me???
>>>>> Roland
>>>>>
>>>>> (forgive me my bad english)
Re: SWTException: Invalid thread access on multiple app-starts [message #107218 is a reply to message #107044] Tue, 30 September 2008 15:10 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Rüdiger,
Please correct me, if I'm wrong, but you don't have to extend from
SessionSingletonBase since getInstance() has been made public.

Sth like this should work:

public class Singleton {
public static Singleton getInstance() {
return (Singleton) SessionSingletonBase.getInstance(Singleton.class);
}
}
}

Regards,
Stefan.

Rüdiger Herrmann schrieb:
> Roland,
>
> please don't 'flood' the newsgroup with the ever same question. Chances
> degrade that your post will be answered at all;)
>
> If the MyComposite is the *actual* use-case for SessionSingletonBase,
> then just don't make it a session-singleton. Each widget has session
> scope since it directly or indirectly belongs to a Display, which in
> turn exists only once per session.
>
> In case the code snippet stands only as an example:
> Undoubtedly, the support for session-singletons as it is currently
> implemented is less-than-ideal. To work around this you could delegate
> to an inner class that extends SessionSingletonBase and holds all
> session-scoped information. There are certainly many more ways to work
> around this. Try to search for "java extend two classes" or similar and
> you will certainly find an answer that suits your needs.
>
> HTH
> Rüdiger
>
Re: SWTException: Invalid thread access on multiple app-starts [message #107233 is a reply to message #107218] Tue, 30 September 2008 15:28 Go to previous messageGo to next message
rollo is currently offline rolloFriend
Messages: 117
Registered: July 2009
Senior Member
Hi,

the problem is fixed.

I was using some static objects.

Thank you to everybody.

Roland


Stefan Roeck schrieb:
> Rüdiger,
> Please correct me, if I'm wrong, but you don't have to extend from
> SessionSingletonBase since getInstance() has been made public.
>
> Sth like this should work:
>
> public class Singleton {
> public static Singleton getInstance() {
> return (Singleton) SessionSingletonBase.getInstance(Singleton.class);
> }
> }
> }
>
> Regards,
> Stefan.
>
> Rüdiger Herrmann schrieb:
>> Roland,
>>
>> please don't 'flood' the newsgroup with the ever same question.
>> Chances degrade that your post will be answered at all;)
>>
>> If the MyComposite is the *actual* use-case for SessionSingletonBase,
>> then just don't make it a session-singleton. Each widget has session
>> scope since it directly or indirectly belongs to a Display, which in
>> turn exists only once per session.
>>
>> In case the code snippet stands only as an example:
>> Undoubtedly, the support for session-singletons as it is currently
>> implemented is less-than-ideal. To work around this you could delegate
>> to an inner class that extends SessionSingletonBase and holds all
>> session-scoped information. There are certainly many more ways to work
>> around this. Try to search for "java extend two classes" or similar
>> and you will certainly find an answer that suits your needs.
>>
>> HTH
>> Rüdiger
>>
Re: SWTException: Invalid thread access on multiple app-starts [message #107245 is a reply to message #107218] Tue, 30 September 2008 16:08 Go to previous message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Stefan,

thanks for correcting this. You are absolutely right. getInstance()
was made public only recently and I forgot about this.

Cheers,
Rüdiger

Stefan Roeck wrote:
> Rüdiger,
> Please correct me, if I'm wrong, but you don't have to extend from
> SessionSingletonBase since getInstance() has been made public.
>
> Sth like this should work:
>
> public class Singleton {
> public static Singleton getInstance() {
> return (Singleton) SessionSingletonBase.getInstance(Singleton.class);
> }
> }
> }
>
> Regards,
> Stefan.
>
> Rüdiger Herrmann schrieb:
>> Roland,
>>
>> please don't 'flood' the newsgroup with the ever same question.
>> Chances degrade that your post will be answered at all;)
>>
>> If the MyComposite is the *actual* use-case for SessionSingletonBase,
>> then just don't make it a session-singleton. Each widget has session
>> scope since it directly or indirectly belongs to a Display, which in
>> turn exists only once per session.
>>
>> In case the code snippet stands only as an example:
>> Undoubtedly, the support for session-singletons as it is currently
>> implemented is less-than-ideal. To work around this you could delegate
>> to an inner class that extends SessionSingletonBase and holds all
>> session-scoped information. There are certainly many more ways to work
>> around this. Try to search for "java extend two classes" or similar
>> and you will certainly find an answer that suits your needs.
>>
>> HTH
>> Rüdiger
>>
Previous Topic:uploading files with CustomServiceHandlers
Next Topic:java.lang.ExceptionInInitializerError
Goto Forum:
  


Current Time: Fri Mar 29 10:37:27 GMT 2024

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

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

Back to the top