With a set of OSGi bundles is there a way to check before runtime if they are deployed together in an OSGi container, that will be no
org.osgi.framework.BundleException: The bundle "bundle_1.2.3 [n]" could not be resolved. Reason: Missing Constraint: Import-Package:
As information is already in MANIFEST.MF, or other build tools,
it should be possible at compile time to check all Import-Package
and Export-Package
You can install all the bundles into an OSGi Framework and resolve them without starting any. The call to perform the resolve is FrameworkWiring.resolveBundles(null)
. This will return a boolean indicating whether the bundles could be resolved or not.
In order to get more details of the resolution problems, you could try tp start one or more unresolved bundles. Since you know they cannot resolve, there is no danger that they will actually start, but you will get a BundleException
giving the resolution error.
You can use bndtools . It has a resolver that can check if the bundles would resolve and even help you when building the list of bundles.
For Apache karaf there is a validator for karaf feature files which at build time can make sure the bundles are transitively closed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.