Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » InjectionException while obtaining IEventBroker from IEclipseContext
InjectionException while obtaining IEventBroker from IEclipseContext [message #921633] Mon, 24 September 2012 09:40 Go to next message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
Hi,

in a non-model-class (an Action effectively) I want to send an event throght IEventBroker.

To do so, I try to obtain the IEventBroker service from the IEclipseContext:

<code>
IEventBroker broker = (IEventBroker) eclipseContext.get(IEventBroker.class);
</code>

while doing this an InjectionException is thrown saying "Unable to process "EventBroker.logger": no actual value was found for the argument "Logger".

The stacktrace is:

<code>
org.eclipse.e4.core.di.InjectionException: Unable to process "EventBroker.logger": no actual value was found for the argument "Logger".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:392)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:383)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:100)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:318)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:240)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:161)
at org.eclipse.e4.ui.services.events.EventBrokerFactory.compute(EventBrokerFactory.java:33)
at org.eclipse.e4.core.internal.contexts.ValueComputation.get(ValueComputation.java:60)
at org.eclipse.e4.core.internal.contexts.EclipseContext.internalGet(EclipseContext.java:221)
at org.eclipse.e4.core.internal.contexts.EclipseContext.get(EclipseContext.java:192)
at org.eclipse.e4.core.internal.contexts.EclipseContext.get(EclipseContext.java:544)
at ch.eugster.webdav.application.handlers.UploadFileHandler.run(UploadFileHandler.java:40)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4134)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3980)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3619)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:150)
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:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
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:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
</code>

What am I doing wrong?
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921640 is a reply to message #921633] Mon, 24 September 2012 09:46 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

That happens because the framework is unable to inject a logger which the IEB needs. The logger should be there as it is put there by the E4Application. Have you modified the way the logger is put in the context?

In which phase of the application are you trying to inject the IEB?
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921731 is a reply to message #921640] Mon, 24 September 2012 11:30 Go to previous messageGo to next message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
I added a context menu via MenuManager to a TreeViewer. An action in the context menu, obtains an IEclipseContext through EclipseContextFactory.getServiceContext. From this IEclipseContext I obtain the services I use.

How can I add this Logger to the IEventBroker?

Thanks!
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921736 is a reply to message #921731] Mon, 24 September 2012 11:37 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Are you on a pure e4 app or mixed with 3.x ?
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921744 is a reply to message #921736] Mon, 24 September 2012 11:44 Go to previous messageGo to next message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
I am on a pure e4
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921749 is a reply to message #921744] Mon, 24 September 2012 11:48 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Try injecting the IEC with a simple @Inject IEclipseContext as a field or a method parameter in your class as I'm not sure you're getting the right context. The logger is in the application level context by default.
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921767 is a reply to message #921749] Mon, 24 September 2012 12:00 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
The problem is that he's fetching the ServiceContext, but the logger is
only pushed somewhere above (most likely the Application-Context) hence
the exception.

Why are you not creating your Action through the local IEclipseContext
and let you inject that one in your Action?

Tom

Am 24.09.12 13:48, schrieb Sopot Cela:
> Try injecting the IEC with a simple @Inject IEclipseContext as a field
> or a method parameter in your class as I'm not sure you're getting the
> right context. The logger is in the application level context by default.
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921768 is a reply to message #921749] Mon, 24 September 2012 12:06 Go to previous messageGo to next message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
As the Action is not part of the model, I am unable to inject the IEclipseContext this way. Is there another opportunity to use dynamic context menu in a viewer (or swt component)?
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921770 is a reply to message #921767] Mon, 24 September 2012 12:06 Go to previous messageGo to next message
Christian Eugster is currently offline Christian Eugster
Messages: 134
Registered: July 2009
Location: St. Gallen Switzerland
Senior Member
That's a good idea. I will try this!
Re: InjectionException while obtaining IEventBroker from IEclipseContext [message #921806 is a reply to message #921770] Mon, 24 September 2012 12:49 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5407
Registered: July 2009
Senior Member
@Inject
IEclipseContext context;

public void createContextMenu(MenuManager mgr) {
MyAction m = ContextInjectionFactory.make(MyAction.class, context);
mgr.add(m);
}


Am 24.09.12 14:06, schrieb Christian Eugster:
> That's a good idea. I will try this!
Previous Topic:How to change perspective buttons state ?
Next Topic:Scrollbar color
Goto Forum:
  


Current Time: Thu Oct 23 05:19:13 GMT 2014

Powered by FUDForum. Page generated in 0.02868 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software