我正在尝试apache felix
的OSGi样本第一个和第二个示例已安装并正常启动。但是第三个与osgi和以前安装的服务存在依赖关系的示例因找不到类错误而失败。
MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: French dictionary
Bundle-SymbolicName: fr-dict
Bundle-Description: A bundle that registers a French dictionary service
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: tutorial.example2b.Activator
Import-Package: org.osgi.framework,
tutorial.example2.service
注意:我在最后一行之后给了一个新行。
g! start file:/Users/johne/Desktop/bundle-dict-fr.jar 10:18:39
org.osgi.framework.BundleException: Activator start error in bundle fr-dict [11].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2289)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2145)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.gogo.command.Basic.start(Basic.java:739)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:136)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClass(BundleWiringImpl.java:2375)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2159)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1578)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1404)
at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4505)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2220)
... 19 more
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleActivator not found by fr-dict [11]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1610)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 30 more
java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
此后是lb输出,
g! lb 10:19:40
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (5.6.8)|5.6.8
1|Active | 1|jansi (1.16.0)|1.16.0
2|Active | 1|JLine Bundle (3.3.0)|3.3.0
3|Active | 1|Apache Felix Bundle Repository (2.0.10)|2.0.10
4|Active | 1|Apache Felix Gogo Command (1.0.2)|1.0.2
5|Active | 1|Apache Felix Gogo JLine Shell (1.0.6)|1.0.6
6|Active | 1|Apache Felix Gogo Runtime (1.0.6)|1.0.6
7|Active | 1|Service listener example (1.0.0)|1.0.0
8|Active | 1|English dictionary (1.0.0)|1.0.0
11|Resolved | 1|French dictionary (1.0.0)|1.0.0
答案 0 :(得分:0)
两个导入的包之间有换行符:
execute (std::bind2nd (std::mem_fun(&Foo::comp), (const Foo&)b), f1);
你能尝试将两者放在同一行:
Import-Package: org.osgi.framework,
tutorial.example2.service
我想在您当前的Manifest中,导入包被忽略,因为语法无效。因此,您的捆绑包可以很好地解决,但不会导入任何包。当激活器运行时,它找不到任何外部类。
答案 1 :(得分:0)
我有同样的问题,我通过重写Import-Package行修复了它。最初我复制粘贴了清单文件,因此其中可能存在一些非法字符。