ClassNotFoundException for org.osgi.framework.BundleActivator despite of Import-Package

André picture André · Aug 24, 2015 · Viewed 7k times · Source

I tried running a really simple OSGi "Hello World"-style example with an activator after a longer while again and got a ClassNotFoundException for org.osgi.framework.BundleActivator (see stack trace below).

The environment is basic Equinox (org.eclipse.osgi_3.7.2...). All bundles (besides mine) are ACTIVE. I have "org.osgi.framework" in my "Import-Package" declaration in the manifest, and I can see the class in the package dependencies in Eclipse.

Can someone give me a hint on what to try to troubleshoot this?

Kind regards, André

Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleActivator
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 30 more

Answer

André picture André · Aug 24, 2015

Sorry for answering this myself, but others might have a similar confusing issue. What happened was that there was a third party library (in this case Jersey) requiring a newer version of OSGi that I had included. Hence that library could not find (the right version of) BundleActivator.