I have created one workbench application plugin not eclipse rcp application. I have not created any plugin template for that workbench application. Now When I run the workbench application Activator is not calling. I put System.out.println("Insided start()") inside the start method of the Activator.java. But it is not calling the start method. How I make call the start method? But when I make the option,Autostart=true in the runconfiguration,plug-ins, It is starting the activator. But the problem is When I call IWorkbenchWindow window = Workbench.getInstance().getActiveWorkbenchWindow(); It is giving the error message saying could not create the workbench window. This error message is giving only when I make this plugin as AutoStart=true. What couldbe the problem?
As you already saw, you need to manage your OSGi bundle manifest to specify the right activation policy. Note though that:
The
Eclipse-AutoStart
andEclipse-LazyStart
headers have been deprecated in Eclipse 3.4.
As of the OSGi R4.1 specification the lazy activation policy has been adopted by the OSGi specification. The new OSGi bundle manifest headerBundle-ActivationPolicy
can be used to specify a lazy activation policy.The Equinox Framework version 3.4 or later will continue to support the deprecated
Eclipse-LazyStart
andEclipse-AutoStart
headers.
Bundle developers that want their bundles to work across other OSGi Framework implementations should add theBundle-ActivationPolicy
header to their manifest. In most cases you can simply add the following header:
Bundle-ActivationPolicy: lazy
See OSGi LazyStart design.
In your case, you can try Bundle-ActivationPolicy: lazy;exclude:="yourPluginId"
if you want to be sure your plugin starts no matter what.
For getting the Active WorkbenchWindow
, you can use PlatformUI.getWorkbench().getActiveWorkbenchWindow()
as detailed in How to get the project name in eclipse?.
Following are the error message I get..When I use IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
java.lang.IllegalStateException: Workbench has not been created yet. at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92) at myworkbenchplugin.Activator.custom(Activator.java:43) at myworkbenchplugin.Activator.start(Activator.java:36) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:374) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1067) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:561) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:546) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:459) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:440) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)