我想在我的OSGI包中使用这个java库[1] enj-library,它将在KURA eclipse平台下执行。
我将库编译为jar,然后在eclipse“从现有JAR存档插件”下创建了一个新的插件项目
然后我尝试将它添加到我的包中,但它不起作用: 1.我试图导入捆绑包,我在导入和导出中验证了两个清单文件中的版本是否正确,但我发现了这个错误:
org.osgi.framework.BundleException: The bundle "org.eclipse.kura.binding.enocean_1.0.0.201506181418 [70]" could not be resolved. Reason: Missing Constraint: Import-Package: it.polito.elite.enocean.enj.communication; version="1.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
at org.tigris.mtoolkit.iagent.internal.rpc.RemoteBundleAdminImpl.startBundle(RemoteBundleAdminImpl.java:230)
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:606)
at org.tigris.mtoolkit.iagent.internal.pmp.InvocationThread.run(InvocationThread.java:54)
at org.tigris.mtoolkit.iagent.internal.utils.ThreadPool$Worker.run(ThreadPool.java:179)
at java.lang.Thread.run(Thread.java:724)
2.我将其添加为必需的捆绑包但我得到了同样的错误:
org.osgi.framework.BundleException: The bundle "org.eclipse.kura.binding.enocean_1.0.0.201506181349 [70]" could not be resolved. Reason: Missing Constraint: Require-Bundle: EnOceanJavaLibraryplugIn; bundle-version="1.0.0"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:300)
at org.tigris.mtoolkit.iagent.internal.rpc.RemoteBundleAdminImpl.startBundle(RemoteBundleAdminImpl.java:230)
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:606)
at org.tigris.mtoolkit.iagent.internal.pmp.InvocationThread.run(InvocationThread.java:54)
at org.tigris.mtoolkit.iagent.internal.utils.ThreadPool$Worker.run(ThreadPool.java:179)
at java.lang.Thread.run(Thread.java:724)
3.我在类路径中添加了我的包,但是我找到了类未找到异常
java.lang.ClassNotFoundException: org.eclipse.kura.binding.enocean.EnOcean
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:340)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1212)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.createInstance(ServiceComponent.java:493)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.createInstance(ServiceComponentProp.java:272)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:333)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
[1] https://github.com/dog-gateway/enj-library
如何在OSGI捆绑包中包含此库?
非常感谢你的帮助!
答案 0 :(得分:0)
enocean库似乎是一个OSGi包。因此,您应该将其添加到目标平台,并在您自己的包中使用Import-Package来访问您需要的包。