The Activator X for bundle Y is invalid, caused by ClassNotFoundException: X
When starting my OSGi application in eclipse, I get the following error:
org.osgi.framework.BundleException: The activator org.pathvisio.sbgn.SbgnPlugin for bundle org.pathvisio.sbgn is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:157)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:751)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
Caused by: java.lang.ClassNotFoundException: org.pathvisio.sbgn.SbgnPlugin
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:326)
at org.eclipse.osgi.framew开发者_JAVA技巧ork.internal.core.BundleHost.loadClass(BundleHost.java:231)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:150)
... 10 more
This seems to be the same problem as: The activator for bundle is invalid
However, no matter what I try, I keep getting that same error. Even if I change the name of the Activator class to something else, it's still giving me the exact same error using the old class name.
Apparently eclipse is caching something, but I have no idea what or why. I've tried restarting eclipse, and rebuilding all projects in my workspace, but nothing helps.
Here is my MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: org.pathvisio.sbgn
Bundle-SymbolicName: org.pathvisio.sbgn
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.pathvisio.sbgn.Activator
Bundle-ClassPath: lib/activation.jar,
lib/google-collect-snapshot-20090211.jar,
lib/jaxb-api.jar,
lib/jaxb-impl.jar,
lib/jaxb-xjc.jar,
lib/jaxb1-impl.jar,
lib/jsr173_1.0_api.jar,
lib/org.sbgn.jar
Export-Package: org.pathvisio.sbgn
Require-Bundle: com.springsource.org.jdom;bundle-version="1.1.0",
org.pathvisio.core;bundle-version="2.0.11",
org.bridgedb;bundle-version="1.1.0",
org.pathvisio.gui;bundle-version="2.0.11",
org.pathvisio.desktop;bundle-version="2.0.11",
org.bridgedb.bio;bundle-version="1.1.0"
Import-Package: org.osgi.framework;version="1.5.0"
As you can see I renamed the activator class, but it's still reporting the error using the class name that I specified previously.
Add ., to Bundle-classpath and check again. It should work.
I experienced this problem after renaming the package of my Activator class. For anyone else that comes across it, eclipse had updated the references to the Activator in the MANIFEST.MF but not in the plugin.xml. In my case the plugin.xml was pointing to the old application
<extension id="application" point="org.eclipse.core.runtime.applications">
<application>
<run class="old.app.Application">
</run>
</application>
So updated the plugin.xml and everything started up again.
Eclipse caches really something! Go to your launch configuration and open the Settings
tab. Choose the option Clear the configuration area before launching
and try to run again your OSGi application!
Is there no chained exception? One reason is that your bundle does not import org.osgi.framework package. So the class load of your activator fails since your bundle class loader cannot load org.osgi.framework.BundleActivator.
精彩评论