开发者

Starting OSGi bundle

I try to run OSGi plug in in Ecl开发者_开发百科ipse. It is empty bundle, but eclipse always send me errors There are my console messages http://pastebin.com/dqQfpQhd What is wrong?


The problem is that the default target includes many bundles that have nothing to do with your bundle -- typing the command ss when all the error messages have finished will list them.

Here's what you do:

  1. In Eclipse, go to Preferences > Plug-in Development > Target Platform
  2. Create a new empty target definition
  3. In the Locations tab, add a directory containing nothing but the Equinox bundle (which you can copy from the plugins directory of your Eclipse installation, the jar is named something like org.eclipse.osgi_3.7.0.v20110613.jar)
  4. Make sure the new target is active and try running your bundle again


I struggled a lot for “Workbench has not been created yet” the complete day.

But I got the solution by the following steps.-

  1. Go to the Run configuration -> Remove all the target platform jars.
  2. Click on add required bundles.
  3. Check the org.apache.felix.gogo.runtime, org.apache.felix.gogo.shell, org.eclipse.eqinox.console, org.eclipse.osgi and your jar file.
  4. The last and important step. Go to Setting-> check the checkbox of "Clear the configuratation area before launching".
  5. Run the OSGi application now.
  6. Enjoy if it works for you as it worked for me.

Thanks


This is the main problem:

java.lang.IllegalStateException: Workbench has not been created yet.

You're using methods/objects from the workbench or related to the workbench while the workbench itself has not been created yet. Maybe you can delay the activation of the bundle or remove 'workbench' dependencies from the activation/initialisation part of the bundle.


Yikes, back to the beginning. The last line of the log containes a 'Hello World' - is this the expected output from your bundle? Maybe it's not your bundle that causes the errors and warnings on the output. I see some 'mylin' and other stuff too. If possible, add another clean installation of eclipse (no additional bundles/plugins) to your system and try the bundle in that environment.


From a good article on eclipsezone:

This usually comes when someone tries to run a Java application against an OSGi bundle with java -classpath .... . It really means that the workbench plug-in hasn't started yet, and so calls to getWorkbench() fail. This is essentially a race condition, and can be solved by either expressing an explicit dependency on that bundle or bumping up that bundle to a higher start level than the workbench. Generally not seen, but if it is, that's what's happening.

What's the superclass of your own bundle? Because that could introduce a dependency on the workbench.

And - how do 'start' the bundle, from within eclipse or hav you jar'ed it up and put it in the eclipse plugin folder? That could make a difference too.


None of those errors have anything to do with your bundle. As you can see from the "Hello World" output, your bundle is starting just fine.

I believe you are launching Eclipse in the wrong way, probably eagerly activating all the bundles. Eclipse needs to start with most workbench bundles in "lazy activation" mode.

  1. Please specify how you are launching Eclipse. Did you add -console to the eclipse.ini file?
  2. Does this problem occur when you do NOT try to use your own bundle?
  3. How are you installing and activating your own bundle?
  4. Please paste the following files:
    • The MANIFEST.MF from your own bundle
    • config.ini from ECLIPSE_HOME/configuration
    • eclipse.ini from ECLIPSE_HOME


First check the dependencies of the empty plugin. May be you are missing to add a plugin, whcih is not loaded at runtime.

If you have dependencies in your plugin, check hich version of the plugins are used.

Which Java version you have defined in your plugin? Is it higher, than the version you are using at runtime?

Is your plugin loading DLLs? if so, check whether the DLL can be found at runtime.

Edit:

# Workbench has not been created yet. # at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92) # at org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin.start(MonitorUiPlugin.java:145)

What did you define in the start method of the Activator? It sems, that you are using the workbench which is not created yet.


Try to do this before running your bundle:

if(!PlatformUI.isWorkbenchRunning()) {
    PlatformUI.createAndRunWorkbench(PlatformUI.createDisplay(), new WorkbenchAdvisor() {...}); 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜