Hello guys,

we are migrating from Karaf 4.0.5 to 4.0.7 and facing a small issue with the feature resolution. I know that in Karaf 4.0.6 the enforcement of service capabilities when feature is installed became effective.
But in our case we use a filter when consuming the service.

In Java code using DS it looks as follows (we are consuming a service, exposed by org.apache.karaf.cellar.bundle):

    @Reference(service = Synchronizer.class, target = "(resource=bundle)")
protected void bindCellarBundleSynchronizer(Synchronizer cellarBundleSynchronizer) {
        this.cellarBundleSynchronizer = cellarBundleSynchronizer;
    }

and it results in the following header in MANIFEST.MF:

Require-Capability: osgi.service;effective:=active;filter:="(&objectClass=org.apache.karaf.cellar.core.Synchronizer)(resource=bundle))"


Note that the filter apart from standard objectClass contains also the "(resource=bundle)" clause.
And this is the culprit in our case.
Because of that clause our feature fails the installation now:

org.osgi.service.resolver.ResolutionException: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=dx-clustering; type=karaf.feature; version="[7.2.0.0-SNAPSHOT,7.2.0.0-SNAPSHOT]"; filter:="(&(osgi.identity=dx-clustering)(type=karaf.feature)(version>=7.2.0.0-SNAPSHOT)(version<=7.2.0.0-SNAPSHOT))" [caused by: Unable to resolve dx-clustering/7.2.0.0-SNAPSHOT: missing requirement [dx-clustering/7.2.0.0-SNAPSHOT] osgi.identity; osgi.identity=org.jahia.bundles.clustering; type=osgi.bundle; version="[7.2.0.0-SNAPSHOT,7.2.0.0-SNAPSHOT]"; resolution:=mandatory [caused by: Unable to resolve org.jahia.bundles.clustering/7.2.0.0-SNAPSHOT: missing requirement [org.jahia.bundles.clustering/7.2.0.0-SNAPSHOT] osgi.service; effective:=active; filter:="(&(objectClass=org.apache.karaf.cellar.core.Synchronizer)(resource=bundle))"]] at org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)
        at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:235)
        at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:158)
at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:216) at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263) at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176) at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)



The resolution issue is only a feature level.
When I am installing/starting the bundle alone I do not have the issue.

I was able to workaround the issue by overriding the cellar-bundle feature in our descriptor and providing explicit capability for that service with the resource=bundle property, i.e.:


    <feature name="dx-cellar-bundle" ...>
        ...
        <capability>
            
osgi.service;effective:=active;objectClass=org.apache.karaf.cellar.core.Synchronizer;resource=bundle
        </capability>
    </feature>


But I would like to ask for help and advice about the proper handling, please. Are we doing something wrong? Is there a better way to let feature resolver work with service filters more accurately?

Thank you in advance!

Kind regards
Sergiy


--
Sergiy Shyrkov
Software Architect
Jahia Solutions Group SA
http://www.jahia.com

Reply via email to