问题
I'm new with OSGi and I'm having trouble trying to run an example of this library: https://github.com/jitsi/libjitsi
java.lang.NoClassDefFoundError: org/osgi/framework/BundleContext
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at org.jitsi.service.libjitsi.LibJitsi.start(LibJitsi.java:247)
at org.jitsi.service.libjitsi.LibJitsi.start(LibJitsi.java:180)
at com.dotsystem.AVTransmit2.main(AVTransmit2.java:327)
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.BundleContext
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Do I need an external jar for osgi?
回答1:
A class not found exception on a core osgi class, seems that you are missing a jar/framework jar that implements OSGi specification. Check which OSGi implementation your target system supports. If you have choice in choosing you can try,
- Apache felix OSGi
- Eclipse equinox OSGi
回答2:
If you are trying to run example from IntelliJ it may be problem that you haven`t imported maven dependencies. When you import java project into IntelliJ you must also import its dependencies (they are not imported by default).
来源:https://stackoverflow.com/questions/43781490/osgi-java-lang-noclassdeffounderror-org-osgi-framework-bundlecontext