3

I have a Eclipse plugin Bundle I've created which won't go from the RESOLVED state to ACTIVE.

I've tried opening the OSGI console to see why the bundle won't start but there doesn't appear to be any problems. If I type "start bundleid" then it starts as you would expect.

The bundle is using the 'org.eclipse.ui.startup' extension point which I'm using to perform a task during the Eclipse workspace startup.

This is the manifest in use:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: My Bundle
Bundle-SymbolicName: com.joejag.bundle;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Activator: com.joejag.bundle.Activator
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.core.resources
Bundle-Vendor: Joejag
Bundle-RequiredExecutionEnvironment: J2SE-1.5

The bundle is intended to be used by others. So asking them to start up an OSGI console and manually start the bundle isn't a viable solution.

This is the nearest I could get to help on the subject which isn't very helpful.See Wiki Eclipse.

Akhil Jain
  • 13,872
  • 15
  • 57
  • 93
joejag
  • 314
  • 1
  • 9
  • Why exactly do you either need or expect this bundle to be active? What error is occurring as a result of it not being active? If the answer to this is "none", then you have nothing to worry about. RESOLVED is not an error state. – Neil Bartlett Dec 03 '10 at 00:59
  • This bundle contains some code that I would like to be executed on startup. The startup code is not run til the plugin enters ACTIVE state. – joejag Dec 03 '10 at 15:35
  • Executing code on startup is, in general, frowned upon in Eclipse and is not well supported. This is because anything you do during startup will cause Eclipse to start a little bit slower. It may not be so bad for just one bundle, but imagine if hundreds of bundles all wanted to do something during startup... Eclipse would take hours to start! – Neil Bartlett Dec 04 '10 at 02:31
  • To summarise: there is no error here. If you want a bundle to start immediately during startup then you need to edit config.ini, but that is not available to you since your bundle is installed via update site. So you need to find an alternative to having code executed during startup. – Neil Bartlett Dec 04 '10 at 02:35
  • Hi Neil, thanks again for your input. Eclipse supports starting tasks programatically via an Extension Point: http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IStartup.html – joejag Dec 04 '10 at 12:10
  • The IStartup is run once Eclipse has started the Workspace and is an established pattern. Running code from Activator.startup() is indeed frowned upon for the reasons you mentioned. – joejag Dec 04 '10 at 12:12
  • Yes IStartup is an option, sorry that I did not mention it however I have had poor results in the past from using it. Often the extension is completely ignored, and even when the code is executed it tends to be some time after the workbench has started. Of course you should do your own testing, but I would not rely on IStartup. – Neil Bartlett Dec 04 '10 at 22:16
  • Neil is right in that IStartup should be used with caution. Another problem with IStartup is that it is in UI code. If the code that needs to get started is non-ui, then you need to be tricky to have it run if you don't want to add ui dependencies to it. We have had luck in the past with the p2 option I describe below. – Andrew Eisenberg Dec 06 '10 at 17:46
  • @joejag: If you problem resolve, can you accept one answer please? – Tim Jan 14 '11 at 08:22

2 Answers2

5

If you need to set your plugin to autostarted and you are expecting that people will install the plugin through p2, then you need to add a p2.inf file. This file contains some extra install instructions.

Add the following p2.inf file to your metadata directory of your plugin:

instructions.configure = setStartLevel(startLevel:4);
markStarted(started: true);

More information on the p2.inf file can be found here.

Akhil Jain
  • 13,872
  • 15
  • 57
  • 93
Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148
1

I assume you try to start a Eclipse application!? If it the case, please set go into your Eclipse application launch configuration and there into the Plug-Ins tab. Set the parameter Default Auto-Start to true and try it again.

Tim
  • 2,831
  • 1
  • 25
  • 37
  • Thanks fo that. Though this is once the plugin has been installed via an Updatesite rather than from within Eclipse itself. – joejag Dec 03 '10 at 15:26