[英]Running OSGI bundle from OSGI command prompt :Import-package missing constraint
I have a bundle with the following mainfest: 我有一个与以下mainfest捆绑在一起的产品:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloCamera
Bundle-SymbolicName: HelloCamera
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: hellocamera.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: cameraservice, cameraserviceimpl, org.osgi.framework
Layout:
HelloCamera
-> hellocamera
-> Activator.java
And a second bundle with this manifest: 第二个带有此清单的捆绑包:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CameraService
Bundle-SymbolicName: CameraService
Bundle-Version: 1.0.0.qualifier
Bundle-Localization: plugin
Export-Package: cameraservice, cameraserviceimpl
Import-Package: org.osgi.framework
Bundle-Activator: cameraserviceimpl.Activator
Layout:
CameraService
-> cameraservice
-> CameraService.java
-> cameraserviceimpl
-> Activator.java
-> CameraServiceImpl.java
I can run the first bundle from Eclipse and everything works fine as expected. 我可以从Eclipse运行第一个捆绑软件,并且一切正常。 I then exported both bundles as a
CameraService.jar
and HelloCamera.jar
respectivly 然后我分别将两个包分别导出为
CameraService.jar
和HelloCamera.jar
I opened up my OSGI console, java -jar equinox.jar -console
and 我打开了OSGI控制台
java -jar equinox.jar -console
并
osgi> install file:CameraService.jar
osgi> install file:HelloCamera.jar
osgi> ss
id State Bundle
17 INSTALLED HelloCamera_1.0.0.qualifier
18 RESOLVED unknown_0.0.0 [18]
then I get 然后我得到
The Bundle could not be resolved. Reason: Missing Constraint: Import-Package: cameraservice; version="0.0.0"
After searching, 搜索后,
I found the problem was with the manifest files. 我发现问题出在清单文件上。 When exporting the jars in my settings I said use the manifest file already in the folder.
在我的设置中导出jar时,我说使用文件夹中已有的清单文件。
I never looked at what the path was pointing to (assuming eclipse would set it correctly) however Eclipse hadn't changed its location so both jars were using the same Manifest file. 我从没看过路径指向的是什么(假设Eclipse可以正确设置它),但是Eclipse并未更改其位置,因此两个jar都使用相同的Manifest文件。
Lesson learned. 学过的知识。 Always check the form before blindly pressing finish.
总是在盲目按完之前检查表格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.