简体   繁体   English

从OSGI命令提示符运行OSGI捆绑包:导入包缺少约束

[英]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.jarHelloCamera.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.

相关问题 OSGI捆绑包.bnd文件和冲突的导入包语句 - OSGI bundle .bnd file and conflicting import-package statements 为什么此OSGi导入包不起作用? - Why does this OSGi Import-Package not work? OSGI Import-Package:版本vs bundle-version - 有什么区别? - OSGI Import-Package: version vs bundle-version - what's the difference? bundle中未解决的约束,缺少要求osgi.wiring.package - Unresolved constraint in bundle, missing requirement osgi.wiring.package 尽管有Import-Package,但org.osgi.framework.BundleActivator的ClassNotFoundException - ClassNotFoundException for org.osgi.framework.BundleActivator despite of Import-Package 在Virgo-Server中无法解决Import-Package.bundle约束中缺少约束的原因 - In Virgo-Server Import-Package could not be resolved.Caused by missing constraint in bundle constraint 如何修复 Eclipse RCP 中的“缺少约束:Import-Package:”和“Require-Bundle” - How to fix "Missing Constraint: Import-Package:" and "Require-Bundle" in Eclipse RCP 无法从OSGI中的另一个软件包导入一个软件包 - Unable to import package of one bundle from another in OSGI OSGi:Import-Package / Export-Package和Require-Capability / Provide Capability之间有什么区别? - OSGi: What's the difference between Import-Package/Export-Package and Require-Capability/Provide Capability? 缺少约束:Import-Package:无法启动Activator - Missing Constraint: Import-Package: Not able to start Activator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM