Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 8523

Summary: Invalid thread access loading extension point
Product: [Eclipse Project] Platform Reporter: Tim deBoer <deboer>
Component: ResourcesAssignee: DJ Houghton <dj.houghton>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: john.arthorne
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Tim deBoer CLA 2002-01-25 19:14:47 EST
I getting some odd behaviour when a plugin is being loaded. I beleive the 
following is a defect, but perhaps this is a restriction or a clarification is 
required instead.

Plugin com.ibm.etools.server.ui is displaying a wizard containing a tree view. 
When the user selects an object from the tree, it uses an IRunnable to call a 
long running method in a non-ui plugin called com.ibm.etools.server.core. This 
allows the progress bar on the wizard to be used for status.

The com.ibm.etools.server.core plugin tries to load an extension point and uses 
createExecutableExtension(). The extension point is "implemented" by the 
com.ibm.etools.tcpip.monitor, which happens to be a UI plugin.

I've included the code below, and the exception that occurs below that. It 
appears as if the loading of an AbstractUI plugin has a side-effect of checking 
the current selection on the tree. Since this is in an IRunnable and not on the 
main UI thread, an invalid access error occurs.

Shouldn't the AbstractUIPlugin (or maybe WWinPluginAction) check which thread 
it is on and use Display.syncExec() before calling back to the UI? I don't want 
to preload the extension points or use the UI thread for this operation - is 
there another way around this? Thanks.

--------------------

IRunnableWithProgress runnable = new IRunnableWithProgress() {
  public void run(IProgressMonitor monitor) {
    try {
      monitor.beginTask("task", "label", 100);
      // ...
      tempElement = cache.getServerResource(..., monitor);
    } catch (Exception e) {
      Trace.trace("Error creating element", e);
    } finally {
      monitor.done();
    }
  }
};
try {
  getWizard().getContainer().run(true, false, runnable);
} catch (Exception e) {
  Trace.trace("Error with runnable", e);
}

--------------------

Log: Fri Jan 25 15:52:40 EST 2002
2 org.eclipse.core.runtime 2 Problems occurred when invoking code from plug-in: 
org.eclipse.core.runtime.
org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:1887)
	at org.eclipse.swt.SWT.error(SWT.java:1819)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:366)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Tree.getSelection(Tree.java:504)
	at org.eclipse.jface.viewers.TreeViewer.getSelection
(TreeViewer.java:158)
	at org.eclipse.jface.viewers.AbstractTreeViewer.getSelectionFromWidget
(AbstractTreeViewer.java:586)
	at org.eclipse.jface.viewers.StructuredViewer.getSelection
(StructuredViewer.java:365)
	at org.eclipse.ui.internal.SelectionService.getSelection
(SelectionService.java:64)
	at org.eclipse.ui.internal.WWinPluginAction.refreshSelection
(WWinPluginAction.java:128)
	at org.eclipse.ui.internal.WWinPluginAction.refreshActionList
(WWinPluginAction.java:52)
	at org.eclipse.ui.internal.Workbench.refreshPluginActions
(Workbench.java:978)
	at org.eclipse.ui.plugin.AbstractUIPlugin.refreshPluginActions
(AbstractUIPlugin.java:382)
	at org.eclipse.ui.plugin.AbstractUIPlugin.startup
(AbstractUIPlugin.java:421)
	at com.ibm.etools.tcpip.monitor.internal.MonitorServerPlugin.startup
(MonitorServerPlugin.java:238)
	at org.eclipse.core.internal.plugins.PluginDescriptor$1.run
(PluginDescriptor.java:643)
	at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:818)
	at 
org.eclipse.core.internal.plugins.PluginDescriptor.internalDoPluginActivation
(PluginDescriptor.java:655)
	at org.eclipse.core.internal.plugins.PluginDescriptor.doPluginActivation
(PluginDescriptor.java:135)
	at org.eclipse.core.internal.plugins.PluginClassLoader.activatePlugin
(PluginClassLoader.java:52)
	at 
org.eclipse.core.internal.plugins.PluginClassLoader.findClassParentsSelf
(PluginClassLoader.java(Compiled Code))
	at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass
(DelegatingURLClassLoader.java(Compiled Code))
	at org.eclipse.core.internal.boot.DelegatingURLClassLoader.loadClass
(DelegatingURLClassLoader.java(Compiled Code))
	at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
	at 
org.eclipse.core.internal.plugins.PluginDescriptor.createExecutableExtension
(PluginDescriptor.java:79)
	at 
org.eclipse.core.internal.plugins.PluginDescriptor.createExecutableExtension
(PluginDescriptor.java:116)
	at 
org.eclipse.core.internal.plugins.ConfigurationElement.createExecutableExtension
(ConfigurationElement.java:96)
	at 
com.ibm.etools.server.core.internal.ServerConfigurationFactory.getDelegate
(ServerConfigurationFactory.java:30)
	at com.ibm.etools.server.core.internal.ServerConfigurationFactory.create
(ServerConfigurationFactory.java:42)
	at 
com.ibm.etools.server.ui.internal.wizardpage.ElementCreationCache.getServerResou
rce(ElementCreationCache.java:78)
	at 
com.ibm.etools.server.ui.internal.wizardpage.CreateServerResourceWizardPage$8.ru
n(CreateServerResourceWizardPage.java:324)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run
(ModalContext.java:98)
Comment 1 John Arthorne CLA 2002-01-28 12:38:40 EST
I believe this has been fixed.  What build are you using?  Probably a duplicate 
of bug 6623.
Comment 2 Tim deBoer CLA 2002-01-29 11:58:39 EST
Yes, this is a duplicate, and I've verified that it is now fixed in Friday's 
build.
Thanks, John.

*** This bug has been marked as a duplicate of 6623 ***
Comment 3 Tim deBoer CLA 2006-06-14 12:55:58 EDT
Closing.