Reputation: 11228
I'm trying out OSGi samples from apache felix
The first and second examples installed and started fine. But the third example where there is a dependency with osgi and previously installed service fails with class not found error.
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
Note: I have given a new line after the last line.
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
Here is lb output after that,
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
Upvotes: 4
Views: 13064
Reputation: 21
I had the same problem and I got it fixed by rewriting the Import-Package line. Originally I copy-pasted the manifest file so there is propably some illegal character in it.
Upvotes: 2
Reputation: 19606
You have a newline between the two imported packages:
Import-Package: org.osgi.framework,
tutorial.example2.service
Can you try to put both on the same line:
Import-Package: org.osgi.framework, tutorial.example2.service
I guess that in your current Manifest the Import-Package is ignored as the syntax is invalid. So your bundle resolves fine but does not import any packages. When the activator is then run it can not find any external classes.
Upvotes: 1