Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FrameworkEvent ERROR on running a Hello World OSGI Bundle

I am a beginner in OSGI. I followed the following tutorial to do a simple Hello World OSGI Bundle in eclipse. http://www.javaworld.com/javaworld/jw-03-2008/jw-03-osgi1.html?page=2

On running the project, I receive a bunch of errors in the console. Below are these errors:

osgi> !SESSION 2013-07-10 23:23:03.340 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_07
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments:  -dev file:C:/Users/student/workspace/.metadata/.plugins/org.eclipse.pde.core/OSGi Framework/dev.properties -os win32 -ws win32 -arch x86 -consoleLog -console

!ENTRY org.eclipse.debug.ui 4 0 2013-07-10 23:23:08.809
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.debug.internal.ui.DebugUIPlugin.start() of bundle org.eclipse.debug.ui.
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
    at org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager.startup(LaunchingResourceManager.java:546)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.getLaunchingResourceManager(DebugUIPlugin.java:357)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.start(DebugUIPlugin.java:569)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    ... 12 more
Root exception:
java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
    at org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager.startup(LaunchingResourceManager.java:546)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.getLaunchingResourceManager(DebugUIPlugin.java:357)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.start(DebugUIPlugin.java:569)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
    at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
    at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

!ENTRY org.eclipse.equinox.p2.core 4 0 2013-07-10 23:23:10.114
!MESSAGE Provisioning exception
!STACK 1
and other similar errors....

Can you please help me to fix this? Thank you.

like image 750
Traveling Salesman Avatar asked Dec 08 '22 14:12

Traveling Salesman


2 Answers

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

like image 51
Shivam Avatar answered May 17 '23 07:05

Shivam


I am late to the party, but I ran into the exact same problem trying to create the Hello World from javaworld tutorial using eclipse 4.2.

When I deselected all the bundles in the Target Platform and pressed "Add Required Bundles", eclipse only selected

org.eclipse.osgi

Upon running, I then got the error

org.osgi.framework.BundleException: Could not find bundle: org.eclipse.equinox.console

Adding the console and pressing "Add Required Bundles" added

javax.servlet
org.apache.felix.gogo.runtime
org.eclipse.osgi.services

along with org.eclipse.osgi

Running this configuration resulted in

org.osgi.framework.BundleException: Missing required bundle: org.apache.felix.gogo.shell

Finally, adding

org.apache.felix.gogo.shell

got me what I expected.

Hello World!!
osgi> ss
"Framework is launched."


id  State       Bundle
0   ACTIVE      org.eclipse.osgi_3.9.0.v20130529-1710
1   ACTIVE      com.javaworld.sample.HelloWorld_1.0.0.qualifier
8   ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
9   ACTIVE      org.eclipse.equinox.console_1.0.100.v20130429-0953
10  ACTIVE      javax.servlet_3.0.0.v201112011016
11  ACTIVE      org.eclipse.osgi.services_3.3.100.v20130513-1956
12  ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
osgi> 
like image 25
ssenften Avatar answered May 17 '23 07:05

ssenften