BND puts the same package to both export and import sections of manifest.mf

余生长醉 提交于 2019-12-12 14:39:35

问题


I have a Vaadin application, which I'm trying to build as a set of OSGI bundles using Maven + BND.

I can't deploy the bundles To Apache Felix because some dependencies can't be resolved. Apache Felix complains that can't find package XYZ required by bundle "A", although this package is defined in this same bundle!!

I looked at the MANIFEST.MF file generated by Maven + BND and saw that the package (XYZ) from this bundle is added to both "import" and "export" sections. I understand why "export", but why "import"?? Why is the bundle trying to import its own package?

my MANIFEST.MF

Manifest-Version: 1.0
Export-Package: myexample.admin;uses:="com.vaadin.ui,myexample.webshared,
 com.vaadin.terminal,myexample.mvc.view.impl,
 myexample.mvc.model,myexample.mvc.renderer.map.impl,
 myexample.mvc.renderer,myexample.mvc.model.impl,myexample.util"
Built-By: ask
Tool: Bnd-0.0.384
Bundle-Name: admin
Created-By: 1.6.0_21 (Sun Microsystems Inc.)
Bundle-Version: 0
Build-Jdk: 1.6.0_26
Bnd-LastModified: 1315674240833
Bundle-ManifestVersion: 2
Import-Package: myexample.admin;version="1.0",myexample.mvc.model,
 myexample.mvc.model.impl,myexample.mvc.renderer,
 myexample.mvc.renderer.map.impl,myexample.mvc.view.impl,
 myexample.util,myexample.webshared,com.vaadin.terminal,com.vaadin.ui
Bundle-SymbolicName: admin
Include-Resource: ..\classes
Originally-Created-By: Apache Maven Bundle Plugin

回答1:


This is correct behaviour. The explanation is in section 3.5.6 of the OSGi core specification.

Regarding the unresolved error from Felix... this must be related to something else. Please post the actual error message.




回答2:


Niel is, of course correct. To be honest though, I've been very successful with using the noimports:=true to get around this. In my applications, I usually have the following in my maven-bundle-plugin section:

<Export-package>*;noimports:=true</export-package>

This results in all of your packages being exported into OSGi, and none of them will appear in your import-package section. If you only need a couple of your exported packages to not appear in your import-package section, you can set the noimports flag for each individual package. Lastly, this syntax is from BND, so it should also work in your .bnd files.



来源:https://stackoverflow.com/questions/7374524/bnd-puts-the-same-package-to-both-export-and-import-sections-of-manifest-mf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!