Search code examples
eclipseexceptioneclipse-rcpe4

E4 Exception org.eclipse.core.commands.common.NotDefinedException


I'm experiencing a weird behavior in our Eclipse e4 RCP application. We're getting an exception that is simply being printed to StdErr, and which seems to originate from some e4 framework logic deeper down.

The exception is reliably replicable when firing up the application, opening a new dialog (MWindow.class), and opening a Nebula DateChooserCombo inside that dialog.

However, we don't get the exception when the e4 Spy plug-ins are activated in the run configuration. So I looked at the differences of the regular and the spy run configuration. With some trial and error I was able to figure out that when I add the plug-in "org.eclipse.ui" and its required plug-ins the exception doesn't occur any longer.

Now my two questions are:

1) Considering the exception below, is adding "org.eclipse.ui" to the list of loaded plug-ins the correct way to go or is it overkill and just a workaround?

2) If "org.eclipse.ui" is the solution, what is the easiest way to tell PDE to also package this plug-in and its required plug-ins with the final Eclipse RCP Product?

org.eclipse.core.commands.common.NotDefinedException: Cannot get the parent identifier from an undefined context. org.eclipse.ui.contexts.dialog
    at org.eclipse.core.commands.contexts.Context.getParentId(Context.java:197)
    at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.getLevel(ContextSet.java:49)
    at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.compare(ContextSet.java:39)
    at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.compare(ContextSet.java:1)
    at java.util.TimSort.binarySort(TimSort.java:265)
    at java.util.TimSort.sort(TimSort.java:190)
    at java.util.TimSort.sort(TimSort.java:173)
    at java.util.Arrays.sort(Arrays.java:659)
    at java.util.Collections.sort(Collections.java:217)
    at org.eclipse.e4.ui.bindings.internal.ContextSet.<init>(ContextSet.java:77)
    at org.eclipse.e4.ui.bindings.internal.BindingTableManager.createContextSet(BindingTableManager.java:90)
    at org.eclipse.e4.ui.bindings.internal.BindingServiceImpl.setContextIds(BindingServiceImpl.java:177)
    at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:90)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:341)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:176)
    at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener$3.widgetDisposed(ShellActivationListener.java:182)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:123)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1118)
    at org.eclipse.swt.widgets.Widget.release(Widget.java:822)
    at org.eclipse.swt.widgets.Widget.dispose(Widget.java:460)
    at org.eclipse.swt.widgets.Decorations.dispose(Decorations.java:447)
    at org.eclipse.swt.widgets.Shell.dispose(Shell.java:725)
    at zzz.tools.widgets.datechooser.ZzzDateChooserCombo.dropDown(ZzzDateChooserCombo.java:1072)
    at zzz.tools.widgets.datechooser.ZzzDateChooserCombo.popupEvent(ZzzDateChooserCombo.java:767)
    at zzz.tools.widgets.datechooser.ZzzDateChooserCombo$1.handleEvent(ZzzDateChooserCombo.java:574)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1118)
    at org.eclipse.swt.widgets.Decorations.WM_ACTIVATE(Decorations.java:1685)
    at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2193)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4659)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1633)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2117)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050)
    at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3141)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:159)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)

The following stack trace was created when a normal JFace MessageDialog was opened in the same application. Different use case --> same error:

org.eclipse.core.commands.common.NotDefinedException: Cannot get the parent identifier from an undefined context. org.eclipse.ui.contexts.dialog
    at org.eclipse.core.commands.contexts.Context.getParentId(Context.java:197)
    at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.getLevel(ContextSet.java:49)
    at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.compare(ContextSet.java:39)
    at org.eclipse.e4.ui.bindings.internal.ContextSet$CComp.compare(ContextSet.java:1)
    at java.util.TimSort.binarySort(TimSort.java:265)
    at java.util.TimSort.sort(TimSort.java:190)
    at java.util.TimSort.sort(TimSort.java:173)
    at java.util.Arrays.sort(Arrays.java:659)
    at java.util.Collections.sort(Collections.java:217)
    at org.eclipse.e4.ui.bindings.internal.ContextSet.<init>(ContextSet.java:77)
    at org.eclipse.e4.ui.bindings.internal.BindingTableManager.createContextSet(BindingTableManager.java:90)
    at org.eclipse.e4.ui.bindings.internal.BindingServiceImpl.setContextIds(BindingServiceImpl.java:177)
    at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
    at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:90)
    at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.processScheduled(EclipseContext.java:341)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.set(EclipseContext.java:356)
    at org.eclipse.e4.core.internal.contexts.EclipseContext.activate(EclipseContext.java:657)
    at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener$2.run(ShellActivationListener.java:124)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:120)
    at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:74)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1266)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1112)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
    at org.eclipse.swt.widgets.Decorations.WM_ACTIVATE(Decorations.java:1673)
    at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2193)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4659)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1633)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2117)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050)
    at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
    at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
    at org.eclipse.swt.widgets.Shell.open(Shell.java:1244)
    at org.eclipse.jface.window.Window.open(Window.java:799)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:330)
    at zzz.dialogs.StatusmeldungDialog.openNotification(StatusmeldungDialog.java:83)
    at zzz.parts.warnings.display.WarningsPart$3.onFinished(WarningsPart.java:228)
    at zzz.actions.ZzzBackgroundJob$1$2.run(ZzzBackgroundJob.java:139)
    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:4155)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3772)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:159)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)

Solution

  • It looks like Eclipse cannot find the org.eclipse.ui.contexts.dialog binding context.

    You need to define the default Binding Contexts in the Application.e4xmi.

    The base context should be org.eclipse.ui.contexts.dialogAndWindow and it should have two children org.eclipse.ui.contexts.window and org.eclipse.ui.contexts.dialog