I am trying to embed Apache Felix in my application. Its working good except when one of my bundle starts depending on osg.osgi.service.log
.
Here is how I am starting the embedded Felix :
Map<String, Object> config = new HashMap<>();
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.osgi.service.log,my.custom.package");
config.put(FelixConstants.LOG_LEVEL_PROP, "3");
felix = new Felix(config);
try {
felix.start();
} catch (BundleException e) {
//...
}
felix.getBundleContext().installBundle("file:my-bundle.jar").start();
Here is what my bundle Manifest looks like:
Export-Package: my.custom.bundle;uses:="my.custom.package,org.osgi.framework,org.osgi.service.log";version="0.0.1"
Import-Package: my.custom.package,org.osgi.framework;version="[1.5,2)",org.osgi.service.log;version="[1.3,2)"
When my bundle is being installed, I got the following exception log:
org.osgi.framework.BundleException: Unable to resolve my.custom.bundle [1](R 1.0): missing requirement [my.custom.bundle [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.service.log (version>=1.3.0)(!(version>=2.0.0))) Unresolved requirements: [[my.custom.bundle [1](R 1.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.service.log)(version>=1.3.0)(!(version>=2.0.0)))]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
at java.lang.Thread.run(Thread.java:745)
I tried to import to add org.apache.felix.log
to FRAMEWORK_SYSTEMPACKAGES_EXTRA
, or adding the org.apache.felix.log.Activator
to SYSTEMBUNDLE_ACTIVATORS_PROP
without effect.
The best would be if you could install the bundle that contains org.osgi.service.log into your embedded OSGi container.
If you really want to use it from the external classloader, you should specify the version of the package in the org.osgi.framework.system.packages.extra configuration.
config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.osgi.service.log;version="x.x.x",my.custom.package");
Where x.x.x should be replaced with the version of the package you have in your classpath. Should be greater or equal to 1.3.0 and lower than 2.0.0.
I can imagine that you want to use this package from the external classloader only if you register a service that implements this interface in the container application (that embeds the OSGi container).