tags:

views:

75

answers:

2

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?

A: 

As you already saw, you need to manage your OSGi bundle manifest to specify the right activation policy. Note though that:

The Eclipse-AutoStart and Eclipse-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 header Bundle-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 and Eclipse-AutoStart headers.
Bundle developers that want their bundles to work across other OSGi Framework implementations should add the Bundle-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?.

VonC
thanks for the information.still I am getting the same problem. When I used PlatformUI.getWorkbench().getActiveWorkbenchWindow(), it is showing the exception that Workbench has not created. But when I Workbench.getInstance().getActiveWorkbenchWindow(), it is showing window is IWorkbenchWindow is null.One more thing all these exceptions I got when I debug. It was not coming in the console. Any idea why it was not showing inthe console? Some exceptions it is showing in the console.
Bhanu
@Bhanu: do you have the exact error message?
VonC
no I dont have the exact error message. When I debug only came to know that it is throwing exception.. and that exception is Workebnch not created. But when I use the code Workench.getInstance().getActiveWorkebenchWindow(), it returning null.
Bhanu
let me try to get the exact error message..
Bhanu
A: 

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)

Bhanu

related questions