osgi start bundle NoClassDefFoundError

时间:2014-05-05 18:08:51

标签: java osgi

我正在EclipseZone的Neil Bartlett系列中开始使用OSGi。我在http://www.eclipsezone.com/eclipse/forums/t90796.html的第3课。

创建并安装jar文件后,我遇到问题:

org.osgi.framework.BundleException: The activator osgitut.movies.impl.MovieListerActivator for bundle MoviesLister is invalid
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:171)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:679)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:291)
        at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:333)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:209)
        at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:155)
        at org.eclipse.osgi.framework.internal.core.FrameworkConsole.runConsole(FrameworkConsole.java:140)
        at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:104)
        at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
        at java.lang.Class.getConstructor0(Class.java:2723)
        at java.lang.Class.newInstance0(Class.java:345)
        at java.lang.Class.newInstance(Class.java:327)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:166)

这是清单:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Movies Lister
Bundle-SymbolicName: MoviesLister
Bundle-Version: 1.0.0
Bundle-Activator: osgitut.movies.impl.MovieListerActivator
Import-Package: org.osgi.framework,org.osgi.util.tracker,osgitut.movies
Export-Package: osgitut.movies;version="1.0.0",osgitut.movies.impl;version="1.0.0"

看起来缺少osgitut / movies / MovieLister类,但它在我创建的jar文件中。我怀疑我在Manifest中遗漏了一些东西,但我无法弄清楚是什么。

1 个答案:

答案 0 :(得分:2)

你有NoClassDefFoundError表示MovieListener类本身并不完整,并且依赖于超类或者有一个成员无法在该包中解析该类。