Home » Eclipse Projects » Remote Application Platform (RAP) » Invalid thread access thrown when calling TreeViewer.refresh()(Invalid thread access thrown when calling TreeViewer.refresh())
Invalid thread access thrown when calling TreeViewer.refresh() [message #902146] |
Thu, 16 August 2012 06:41 |
Thongchai Sukosi Messages: 7 Registered: August 2012 |
Junior Member |
|
|
Hi,
I am very new to RAP. I built a simple application for testing RAP features as part of evaluation process. My applicaiton was just a simple application displaying a simple tree strcutrue model through JFace TreeeViewer as well as having a delete action that delete a tree member, and then simply called TreeViewer.refresh() to update the presentation layer. (To be more specific, my application is based on Hyperbola example from one of Eclipse RCP books)
Well, the applicatoin was running fine in either Eclipse IDE or Web Broser(IE); but not both! When I opened the application in Eclipse IDE and IE at the same time, and then tried delete action, then "Invalid thread access" exception was thrown from TreeViewer.refresh(). I have tried some techniques I found from google like Job, Display.asyncExec, UICallback, etc. They didn't help. I couldn't figure out how to solve the problem.
Can anybody please help. Thank you in advance.
!ENTRY org.eclipse.rap.ui 4 0 2555-08-16 13:10:30.139
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:3531)
at org.eclipse.swt.SWT.error(SWT.java:3454)
at org.eclipse.swt.SWT.error(SWT.java:3425)
at org.eclipse.swt.widgets.Widget.error(Widget.java:962)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:902)
at org.eclipse.swt.widgets.Tree.getSelection(Tree.java:660)
at org.eclipse.jface.viewers.TreeViewer.getSelection(TreeViewer.java:256)
at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:344)
at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2458)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1751)
at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2907)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1432)
at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:403)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1386)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1488)
at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:536)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1447)
at org.example.rap.hyperbola.contact.ContactView$1.consume(ContactView.java:37)
at org.example.evenbus.InMemoryEvenBus.broadCast(InMemoryEvenBus.java:61)
at org.example.rap.hyperbola.contact.DeleteContactAction.run(DeleteContactAction.java:83)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:493)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:575)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:492)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:443)
at org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatchEvent(UntypedEventAdapter.java:646)
at org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetSelected(UntypedEventAdapter.java:90)
at org.eclipse.swt.events.SelectionEvent.dispatchToObserver(SelectionEvent.java:191)
at org.eclipse.rwt.internal.events.Event.processEvent(Event.java:46)
at org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.java:186)
at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.java:208)
at org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1145)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1135)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2733)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:685)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
at org.example.rap.hyperbola.Application.start(Application.java:20)
at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:289)
at java.lang.Thread.run(Unknown Source)
at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
[Updated on: Thu, 16 August 2012 07:20] Report message to a moderator
|
|
|
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #902163 is a reply to message #902146] |
Thu, 16 August 2012 08:00 |
Ivan Furnadjiev Messages: 2429 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
the error means that you are trying to refresh your viewer from a
background thread. It's strange that the error appears only if you have
more than one user session active. Without the actual code I can't help
you much.
Best,
Ivan
On 8/16/2012 9:41 AM, Thongchai Sukosi wrote:
> Hi,
>
> I am very new to RAP. I built a simple application for testing RAP
> features as part of evaluation process. My applicaiton was just a
> simple application displaying a simple tree strcutrue model through
> JFace TreeeViewer as well as having a delete action that delete a tree
> member, and then simply called TreeViewer.refresh() to update the
> presentation layer. (To be more specific, my application is based on
> Hyperbola example from one of Eclipse RCP books)
>
> Well, the applicatoin was running fine in either Eclipse IDE or Web
> Broser(IE); but not both! When I opened the application in Eclipse IDE
> and IE at the same time, and then tried delete action, then "Invalid
> thread access" exception was thrown from TreeViewer.refresh(). I have
> tried some techniques I found from google like Job, Display.asyncExec,
> UICallback, etc. They didn't help. I couldn't figure out how to solve
> the problem.
> Can anybody please help. Thank you in advance.
>
> !ENTRY org.eclipse.rap.ui 4 0 2555-08-16 13:10:30.139
> !MESSAGE Unhandled event loop exception
> !STACK 0
> org.eclipse.swt.SWTException: Invalid thread access
> at org.eclipse.swt.SWT.error(SWT.java:3531)
> at org.eclipse.swt.SWT.error(SWT.java:3454)
> at org.eclipse.swt.SWT.error(SWT.java:3425)
> at org.eclipse.swt.widgets.Widget.error(Widget.java:962)
> at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:902)
> at org.eclipse.swt.widgets.Tree.getSelection(Tree.java:660)
> at
> org.eclipse.jface.viewers.TreeViewer.getSelection(TreeViewer.java:256)
> at
> org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:344)
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2458)
> at
> org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1751)
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2907)
> at
> org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1432)
> at
> org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:403)
> at
> org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1386)
> at
> org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1488)
> at
> org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:536)
> at
> org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1447)
> at
> org.example.rap.hyperbola.contact.ContactView$1.consume(ContactView.java:37)
> at
> org.example.evenbus.InMemoryEvenBus.broadCast(InMemoryEvenBus.java:61)
> at
> org.example.rap.hyperbola.contact.DeleteContactAction.run(DeleteContactAction.java:83)
> at org.eclipse.jface.action.Action.runWithEvent(Action.java:493)
> at
> org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:575)
> at
> org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:492)
> at
> org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:443)
> at
> org.eclipse.swt.internal.widgets.UntypedEventAdapter.dispatchEvent(UntypedEventAdapter.java:646)
> at
> org.eclipse.swt.internal.widgets.UntypedEventAdapter.widgetSelected(UntypedEventAdapter.java:90)
> at
> org.eclipse.swt.events.SelectionEvent.dispatchToObserver(SelectionEvent.java:191)
> at org.eclipse.rwt.internal.events.Event.processEvent(Event.java:46)
> at
> org.eclipse.swt.events.TypedEvent.processEvent(TypedEvent.java:186)
> at org.eclipse.swt.events.TypedEvent.executeNext(TypedEvent.java:208)
> at
> org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1145)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1135)
> at
> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2733)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
> at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:685)
> at
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
> at org.example.rap.hyperbola.Application.start(Application.java:20)
> at
> org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:289)
> at java.lang.Thread.run(Unknown Source)
> at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
| | |
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #902357 is a reply to message #902324] |
Fri, 17 August 2012 09:45 |
Chris Fairhall Messages: 221 Registered: February 2011 |
Senior Member |
|
|
Quote:1.) Though, it's not the best solution; but for my evaluation phase, this is good enough. By the way I am wondering if there is any already-exist of something like event bus in RAP (event producer doesn't have to couple with event consumers).
Not that I'm aware of.
Quote:2.) I saw when I was debugging the program that each RAP user session would always be executed by the thread that created it. What if that thread is killed by external process? Will it caused the associated RAP user session to be fail as well?
Yes, the if the thread is killed, the session will be disposed. You should never call Thread.stop()
Quote:3.) Is it always the case that the RAP user session needs to be executed on the same thread that created, or there are other options? If the number of RAP user sessions exceeds the number of maximum threads allow for that environment, how RAP should behaves?
When run in SWT compatibility mode, yes. When run in JEE mode, no. But the workbench can't be used in JEE mode.
If you need to scale in SWT mode, look at a load balancer with session affinity and multiple RAP servers behind it.
|
|
| | | | |
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #903522 is a reply to message #903194] |
Fri, 24 August 2012 06:41 |
Thongchai Sukosi Messages: 7 Registered: August 2012 |
Junior Member |
|
|
Dear Thomas,
Thank you again for your reply. While I am considering your solution, one thing come up on my mind.
- Suppose when I do this ...
BundleContext ctx = FrameworkUtil.getBundle(SenderView.class).getBundleContext();
ServiceReference<EventAdmin> ref = ctx.getServiceReference(EventAdmin.class);
EventAdmin eventAdmin = ctx.getService(ref);
1. Is the EventAdmin obtained above singleton?
2. If so, does it have a dedicated thread for fetching and broadcasting events?
3. If so, it means that all user sessions in RAP depend on that dedicated thread to broadcast events of their interest. Will it cause any scalibility or concurrency issue?
Please kindly advice.
Thank you in advance.
[Updated on: Fri, 24 August 2012 09:44] Report message to a moderator
|
|
| |
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #903719 is a reply to message #903685] |
Sat, 25 August 2012 02:36 |
Thongchai Sukosi Messages: 7 Registered: August 2012 |
Junior Member |
|
|
Dear,
Pls do not get me wrong. I'm really appricated you guys answering many many questions from novices like me.
By the way since this topic have been read by thousands of people and might be more people to read it in the future. Thus I would like to make it clear for others.
Firstly I do not worry about whether or not EventAdmin can support any types of OSGI-Application, because I am pretty sure it does well on serving its original design goal so as to provide a mean of communication amoung OSGI bundles even with fews threads are involved. The good example is Eclipse IDE.
But as the matter of fact, my originally question is asking about whether or not a decouple event mechanism (the practical one) is there for RAP or developers need to seek for another solution.
Fortunately I just found this information from eclipsesource.com blogs this morning (my bad!). Sorry that I am unable to post the web link. The information has been published by 'Ralf Sternberg' since 16-JUL-12. If it is correct, it might be a conclusion as well as hope to the question.
[Below is a part of the information]
"However, even with these changes, the Eclipse 4 workbench is not yet capable of handling multiple user sessions. One known problem is that events are broadcast using the OSGi event admin service. In RAP all user sessions share a single instance of this service. However, I've learned that the event admin service is never accessed directly by E4 code, but always through an event broker interface in from the current context, which should make this problem much easier to fix."
Thank you once again.
[Updated on: Sat, 25 August 2012 04:20] Report message to a moderator
|
|
|
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #904003 is a reply to message #903719] |
Mon, 27 August 2012 14:37 |
Eclipse User |
|
|
|
Hi,
we now face the same question. We need to send events and listen to
those. The EventAdmin is not the correct solution for RAP applications
as this does not seem to be able to work with multiple users. If one
user fires an event, than all other user sessions will be notifed of
this event. Great for a chat application, but not for updating views etc. .
For now, it seems that we need to build our own solution, like an
EventManager that is a SessionSingleton or something like this.
Regards,
Markus
Am 25.08.2012 04:36, schrieb Thongchai Sukosi:
> Dear,
>
> Pls do not get me wrong. I'm really appricated you guys, answering many
> many questions from novices like me.
>
> By the way since this topic have been read by thousands of people and
> might be more people to read it in the future. Thus I would like to make
> it clear for others.
>
> Firstly I do not worry about whether or not EventAdmin can support any
> types of OSGI-Application, because I am pretty sure it does well on
> serving its original design goal so as to provide a mean of
> communication amoung OSGI bundles even with fews threads are involved.
> The good example is Eclipse IDE.
>
> But as the matter of fact, my originally question is asking about
> whether or not a decouple event mechanism (the practical one) is there
> for RAP or developers need to seek for another solution.
>
> Fortunately I just found this information from eclipsesource.com blogs
> this morning (my bad!). Sorry that I am unable to post the web link. The
> information was published since 16-JUL-12. If it is correct, it might be
> a conclusion as well as hope to the question.
>
> [Below is a part of the information]
> "However, even with these changes, the Eclipse 4 workbench is not yet
> capable of handling multiple user sessions. One known problem is that
> events are broadcast using the OSGi event admin service. In RAP all user
> sessions share a single instance of this service. However, I've learned
> that the event admin service is never accessed directly by E4 code, but
> always through an event broker interface in from the current context,
> which should make this problem much easier to fix."
>
> Thank you once again.
|
|
|
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #904055 is a reply to message #904003] |
Mon, 27 August 2012 16:32 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Did you read my idea? You can simply scope the event to a session by
prefixing all your events with it.
So if you have "clientA" and "clientB" and upon launch give them a
unique key (e.g. the session) which I'd name $clientId and prefix all
your your EventAdmin-Events and Subscribtions with $clientId+"/...." you
can use the EventAdmin in a multi-user env (This is BTW the proposed
solution for e4 and works already in the e4 vaadin port).
Tom
Am 27.08.12 16:37, schrieb Markus Krüger:
> Hi,
>
> we now face the same question. We need to send events and listen to
> those. The EventAdmin is not the correct solution for RAP applications
> as this does not seem to be able to work with multiple users. If one
> user fires an event, than all other user sessions will be notifed of
> this event. Great for a chat application, but not for updating views etc. .
>
> For now, it seems that we need to build our own solution, like an
> EventManager that is a SessionSingleton or something like this.
>
> Regards,
> Markus
>
> Am 25.08.2012 04:36, schrieb Thongchai Sukosi:
>> Dear,
>>
>> Pls do not get me wrong. I'm really appricated you guys, answering many
>> many questions from novices like me.
>>
>> By the way since this topic have been read by thousands of people and
>> might be more people to read it in the future. Thus I would like to make
>> it clear for others.
>>
>> Firstly I do not worry about whether or not EventAdmin can support any
>> types of OSGI-Application, because I am pretty sure it does well on
>> serving its original design goal so as to provide a mean of
>> communication amoung OSGI bundles even with fews threads are involved.
>> The good example is Eclipse IDE.
>>
>> But as the matter of fact, my originally question is asking about
>> whether or not a decouple event mechanism (the practical one) is there
>> for RAP or developers need to seek for another solution.
>>
>> Fortunately I just found this information from eclipsesource.com blogs
>> this morning (my bad!). Sorry that I am unable to post the web link. The
>> information was published since 16-JUL-12. If it is correct, it might be
>> a conclusion as well as hope to the question.
>>
>> [Below is a part of the information]
>> "However, even with these changes, the Eclipse 4 workbench is not yet
>> capable of handling multiple user sessions. One known problem is that
>> events are broadcast using the OSGi event admin service. In RAP all user
>> sessions share a single instance of this service. However, I've learned
>> that the event admin service is never accessed directly by E4 code, but
>> always through an event broker interface in from the current context,
>> which should make this problem much easier to fix."
>>
>> Thank you once again.
|
|
|
Re: Invalid threadd access thrown when calling TreeViewer.refresh() [message #904893 is a reply to message #904055] |
Wed, 29 August 2012 10:33 |
Eclipse User |
|
|
|
Ah, ok, didn'T get that. Thank you, we'll try.
Am 27.08.2012 18:32, schrieb Tom Schindl:
> Did you read my idea? You can simply scope the event to a session by
> prefixing all your events with it.
>
> So if you have "clientA" and "clientB" and upon launch give them a
> unique key (e.g. the session) which I'd name $clientId and prefix all
> your your EventAdmin-Events and Subscribtions with $clientId+"/...." you
> can use the EventAdmin in a multi-user env (This is BTW the proposed
> solution for e4 and works already in the e4 vaadin port).
|
|
|
Goto Forum:
Current Time: Thu Jan 16 01:35:45 GMT 2025
Powered by FUDForum. Page generated in 0.04581 seconds
|