问题
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
回答1:
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.
回答2:
Make sure there is a line break after the last line of the
manifest
来源:https://stackoverflow.com/questions/32179689/classnotfoundexception-for-org-osgi-framework-bundleactivator-despite-of-import