Eclipse plugin bundle stuck in Starting state

北城以北 提交于 2019-12-22 06:49:28

问题


I used Eclipse to create a new plug-in project which created a default Activator for me. When debugging (running as Eclipse Application) I noticed the start() and stop() methods of this activator weren't called.

Following the guide on what to do when your bundle isn't visible in Eclipse I stumbled upon the following results.

  • Using the ss command, I can see my bundle listed.
  • The status of my bundle is 'Starting'

The bundle is in the process of starting. A bundle is in the STARTING state when its start method is active. A bundle must be in this state when the bundle's BundleActivator.start(BundleContext) is called. If the BundleActivator.start method completes without exception, then the bundle has successfully started and must move to the ACTIVE state.

A breakpoint placed on the first line in the start method doesn't get hit. Neither does System.out.println show up in the console. What could cause the start method not getting called, and thus the state being stuck in STARTING?


回答1:


The following doesn't address the fact that the OSGi console reports the plugin to be STARTING, but it is an approach by which I got my plugin to start right after Eclipse started up.

As Chris Gerken points out in a comment, the startup code is only run when you try to use one of the plugin extensions.

Using the org.eclipse.ui.startup extension you can register a plugin that wants to be activated on startup. It is possible to set this up by using the manifest editor.

  1. Add org.eclipse.ui as a dependency in the "Dependencies" tab.
  2. In the "Extensions" tab add the Startup extension (org.eclipse.ui.startup).
  3. Underneath "Extension Element Details" provide a class which implements org.eclipse.ui.IStartup.

TaskManager.java

public class TaskManager implements IStartup
{
    @Override
    public void earlyStartup()
    {
        // This will get called when Eclipse is started,
        // after the GUI has been initialized.
    }
}


来源:https://stackoverflow.com/questions/13799093/eclipse-plugin-bundle-stuck-in-starting-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!