Discussion:
Feature resolution for service capabilities of services with filters
Sergiy Shyrkov
2016-10-12 11:30:27 UTC
Permalink
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
David Jencks
2016-10-12 17:41:53 UTC
Permalink
What is generating the Require-Capabiility header? The target filter isn’t supposed to be there on either Provide- or Require-Capability since it can generally be overridden by configuration. AFAICT the bnd DS processing doesn’t add the target filter to the Require-Capability header.

david jencks
Post by Sergiy Shyrkov
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.
@Reference(service = Synchronizer.class, target = "(resource=bundle)")
protected void bindCellarBundleSynchronizer(Synchronizer cellarBundleSynchronizer) {
this.cellarBundleSynchronizer = cellarBundleSynchronizer;
}
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.
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.
<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
Guillaume Nodet
2016-10-12 18:13:54 UTC
Permalink
The bnd plugin from the maven bundle plugin used to do that:

https://github.com/apache/felix/blob/trunk/tools/maven-bundle-plugin/src/main/resources/org/apache/felix/bundleplugin/scr.xsl
I think it's now disabled by default and the bnd one is used.

Maybe an upgrade of the maven bundle plugin would fix the problem ?
Post by David Jencks
What is generating the Require-Capabiility header? The target filter
isn’t supposed to be there on either Provide- or Require-Capability since
it can generally be overridden by configuration. AFAICT the bnd DS
processing doesn’t add the target filter to the Require-Capability header.
david jencks
Post by Sergiy Shyrkov
Hello guys,
we are migrating from Karaf 4.0.5 to 4.0.7 and facing a small issue with
the feature resolution.
Post by Sergiy Shyrkov
I know that in Karaf 4.0.6 the enforcement of service capabilities when
feature is installed became effective.
Post by Sergiy Shyrkov
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,
@Reference(service = Synchronizer.class, target = "(resource=bundle)")
protected void bindCellarBundleSynchronizer(Synchronizer
cellarBundleSynchronizer) {
Post by Sergiy Shyrkov
this.cellarBundleSynchronizer = cellarBundleSynchronizer;
}
Require-Capability: osgi.service;effective:=
active;filter:="(&objectClass=org.apache.karaf.cellar.core.
Synchronizer)(resource=bundle))"
Post by Sergiy Shyrkov
Note that the filter apart from standard objectClass contains also the
"(resource=bundle)" clause.
Post by Sergiy Shyrkov
And this is the culprit in our case.
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))"]]
Post by Sergiy Shyrkov
at org.apache.felix.resolver.ResolutionError.toException(
ResolutionError.java:42)
Post by Sergiy Shyrkov
at org.apache.felix.resolver.ResolverImpl.resolve(
ResolverImpl.java:235)
Post by Sergiy Shyrkov
at org.apache.felix.resolver.ResolverImpl.resolve(
ResolverImpl.java:158)
Post by Sergiy Shyrkov
at org.apache.karaf.features.internal.region.
SubsystemResolver.resolve(SubsystemResolver.java:216)
Post by Sergiy Shyrkov
at org.apache.karaf.features.internal.service.Deployer.
deploy(Deployer.java:263)
Post by Sergiy Shyrkov
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.
doProvision(FeaturesServiceImpl.java:1176)
Post by Sergiy Shyrkov
at org.apache.karaf.features.internal.service.
FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)
Post by Sergiy Shyrkov
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1142)
Post by Sergiy Shyrkov
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:617)
Post by Sergiy Shyrkov
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
Post by Sergiy Shyrkov
<feature name="dx-cellar-bundle" ...>
...
<capability>
osgi.service;effective:=active;objectClass=org.apache.
karaf.cellar.core.Synchronizer;resource=bundle
Post by Sergiy Shyrkov
</capability>
</feature>
But I would like to ask for help and advice about the proper handling,
please.
Post by Sergiy Shyrkov
Are we doing something wrong? Is there a better way to let feature
resolver work with service filters more accurately?
Post by Sergiy Shyrkov
Thank you in advance!
Kind regards
Sergiy
--
Sergiy Shyrkov
Software Architect
Jahia Solutions Group SA
http://www.jahia.com
--
------------------------
Guillaume Nodet
------------------------
Red Hat, Open Source Integration

Email: ***@redhat.com
Web: http://fusesource.com
Blog: http://gnodet.blogspot.com/
Sergiy Shyrkov
2016-10-13 12:57:53 UTC
Permalink
Thank you for the answer Guillaume and David!

We were using maven-bundle-plugin (2.5.x) for building the bundles.
Switching to the latest version of the plugin (3.2.0) changes the things:
the Provide-Capability/Require-Capability headers no longer contain
service properties for filters, but only objectClass attribute.
I will verify on our side in how far such an upgrade can be done.

Thank you once again, so far I have solutions for the issue!

Kind regards
Sergiy
Post by Guillaume Nodet
https://github.com/apache/felix/blob/trunk/tools/maven-bundle-plugin/src/main/resources/org/apache/felix/bundleplugin/scr.xsl
I think it's now disabled by default and the bnd one is used.
Maybe an upgrade of the maven bundle plugin would fix the problem ?
Post by David Jencks
What is generating the Require-Capabiility header? The target filter
isn’t supposed to be there on either Provide- or Require-Capability
since it can >>generally be overridden by configuration. AFAICT the
bnd DS processing doesn’t add the target filter to the
Require-Capability header.
Post by David Jencks
david jencks
On Oct 12, 2016, at 4:30 AM, Sergiy Shyrkov
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,
@Reference(service = Synchronizer.class, target =
"(resource=bundle)")
protected void bindCellarBundleSynchronizer(Synchronizer
cellarBundleSynchronizer) {
this.cellarBundleSynchronizer = cellarBundleSynchronizer;
}
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.
missing requirement [root] osgi.identity; osgi.identity=dx-clustering;
Post by David Jencks
Post by Sergiy Shyrkov
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
Post by David Jencks
Post by Sergiy Shyrkov
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
<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
--------------------------
Guillaume Nodet
------------------------
Red Hat, Open Source Integration
Web: http://fusesource.com
Blog: http://gnodet.blogspot.com/
--
Sergiy Shyrkov
Software Architect
Jahia Solutions Group SA
http://www.jahia.com
Loading...