title: Exception while dispatching event org.osgi.service.event.Event error while running SWTBot tests using ant
body: <p>I am running the SWT-Bot tests using ant. The eclipse opens properly and runs the test cases. But very frequently I see the following error,</p>
  
  <pre><code>!MESSAGE Exception while dispatching event org.osgi.service.event.Event [topic=org/eclipse/e4/ui/model/ui/UIElement/visible/SET] to handler org.eclipse.e4.ui.services.internal.events.UIEventHandler@29fcf1ba
  !STACK 0
  java.lang.IllegalArgumentException: Argument not valid
      at org.eclipse.swt.SWT.error(SWT.java:4378)
      at org.eclipse.swt.SWT.error(SWT.java:4312)
      at org.eclipse.swt.SWT.error(SWT.java:4283)
      at org.eclipse.swt.widgets.Widget.error(Widget.java:481)
      at org.eclipse.swt.widgets.Control.setParent(Control.java:4505)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.handleEvent(PartRenderingEngine.java:206)
      at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
      at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
      at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
      at org.eclipse.swt.widgets.Display.syncExec(Display.java:4491)
      at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:205)
      at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
      at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
      at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
      at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
      at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
      at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
      at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
      at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
      at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
      at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setVisible(UIElementImpl.java:332)
      at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.clearTR(StackRenderer.java:559)
      at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.adjustTR(StackRenderer.java:567)
      at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1107)
      at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:66)
      at org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:41)
      at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:180)
      at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
      at org.eclipse.swt.widgets.Display.syncExec(Display.java:4491)
      at org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:205)
      at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
      at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)
      at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
      at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
      at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
      at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
      at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:80)
      at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:58)
      at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
      at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:171)
      at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:576)
      at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:543)
      at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:610)
      at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:322)
      at org.eclipse.ui.internal.WorkbenchPage.bringToTop(WorkbenchPage.java:963)
      at org.eclipse.ui.internal.console.ConsoleManager$ShowConsoleViewJob.runInUIThread(ConsoleManager.java:314)
      at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
      at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
      at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
      at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3717)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3366)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
      at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
      at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
      at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      at org.eclipse.swtbot.eclipse.core.UITestApplication.start(UITestApplication.java:54)
      at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
      at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
  </code></pre>
  
  <p>If this error occurs then results are not posted onto the file, however the output of ant says that test have run properly.<br/>
  <strong>This issue happens with both Juno and Kepler</strong>(I am using latest juno and kepler).<br/>Is this a know issue and if so is there any fix for this? If not, any workaround to avoid this?</p>