This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 427731 - Using @OSGiBundle in @Execute throws IllegalArgumentException
Summary: Using @OSGiBundle in @Execute throws IllegalArgumentException
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.4   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 4.4 M6   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-08 11:22 EST by Paul Webster CLA
Modified: 2014-03-04 12:35 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2014-02-08 11:22:21 EST
I added @OSGiContext to my @Execute method and I get the following exception.


@Execute
public void execute(
	@OSGiBundle BundleContext bundleContext,
	@Named("org.eclipse.e4.examples.di.product.pluginLocation") String pluginLocation,
	@Optional Logger logger) {


!ENTRY org.eclipse.e4.ui.workbench 4 0 2014-02-08 08:18:05.021
!MESSAGE Internal Error
!STACK 0
java.lang.IllegalArgumentException
	at org.eclipse.osgi.internal.framework.BundleContextImpl.removeBundleListener(BundleContextImpl.java:336)
	at org.eclipse.e4.core.di.internal.extensions.OSGiObjectSupplier.untrack(OSGiObjectSupplier.java:75)
	at org.eclipse.e4.core.di.internal.extensions.OSGiObjectSupplier.get(OSGiObjectSupplier.java:50)
	at org.eclipse.e4.core.internal.di.InjectorImpl.resolveArgs(InjectorImpl.java:456)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:239)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:153)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:222)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:776)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:668)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$6(HandledContributionItem.java:652)
	at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:584)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4423)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3771)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3391)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1122)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1006)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:147)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:166)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:80)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:372)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:226)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:611)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1462)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Thomas Watson CLA 2014-02-10 08:50:17 EST
(In reply to Paul Webster from comment #0)
> !ENTRY org.eclipse.e4.ui.workbench 4 0 2014-02-08 08:18:05.021
> !MESSAGE Internal Error
> !STACK 0
> java.lang.IllegalArgumentException
> 	at
> org.eclipse.osgi.internal.framework.BundleContextImpl.
> removeBundleListener(BundleContextImpl.java:336)
> 	at
> org.eclipse.e4.core.di.internal.extensions.OSGiObjectSupplier.
> untrack(OSGiObjectSupplier.java:75)

In case you were wondering, this is because a null BundleListener is being passed to the BundleContext.removeBundleListener method.
Comment 2 Markus Kuppe CLA 2014-02-12 16:24:28 EST
Here's a fix https://git.eclipse.org/r/21917
Comment 3 Paul Webster CLA 2014-02-12 16:28:58 EST
Thanks Markus

PW
Comment 5 Paul Webster CLA 2014-03-04 12:35:26 EST
In 4.4.0.I20140303-2000

PW