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 08:37  |
Eclipse User |
|
|
|
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 13:38   |
Eclipse User |
|
|
|
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 06:50   |
Eclipse User |
|
|
|
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 07:34   |
Eclipse User |
|
|
|
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 #107233 is a reply to message #107218] |
Tue, 30 September 2008 11:28   |
Eclipse User |
|
|
|
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 12:08  |
Eclipse User |
|
|
|
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
>>
|
|
|
Goto Forum:
Current Time: Sat May 10 18:15:05 EDT 2025
Powered by FUDForum. Page generated in 0.04820 seconds
|