在eclipse中启动我的OSGi应用程序时,出现以下错误:
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.framework.internal.core.BundleHost.loadClass(BundleHost.java:231)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:150)
... 10 more
这似乎与以下问题相同: The activator for bundle is invalid
但是,无论我尝试什么,我都会遇到同样的错误。即使我将Activator类的名称更改为其他名称,它仍然使用旧类名给我完全相同的错误。
显然eclipse正在缓存某些东西,但我不知道是什么或为什么。 我已经尝试重新启动eclipse,并在我的工作区重建所有项目,但没有任何帮助。
这是我的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"
正如您所看到的,我重命名了激活器类,但它仍然使用我之前指定的类名报告错误。
答案 0 :(得分:6)
添加。,到Bundle-classpath并再次检查。它应该工作。
答案 1 :(得分:1)
重命名Activator类的包后,我遇到了这个问题。对于遇到它的任何其他人,eclipse已经更新了MANIFEST.MF中对Activator的引用,但没有在plugin.xml中更新。在我的例子中,plugin.xml指向旧的应用程序
<extension id="application" point="org.eclipse.core.runtime.applications">
<application>
<run class="old.app.Application">
</run>
</application>
所以更新了plugin.xml,一切都重新启动了。
答案 2 :(得分:0)
Eclipse缓存真的很棒!转到启动配置并打开Settings
标签。选择Clear the configuration area before launching
选项并尝试再次运行OSGi应用程序!
答案 3 :(得分:0)
是否没有链接异常?一个原因是您的包不会导入org.osgi.framework包。因此,激活器的类加载失败,因为bundle类加载器无法加载org.osgi.framework.BundleActivator。