You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Frank_S <fr...@ikan.be> on 2016/12/12 14:16:00 UTC

Problems after removing a feature repository in Karaf 4.0

Hi,

we run our application in Karaf. It has a pluggable architecture in the
sense that extra bundles get installed that perform certain services. The
services are defined using Blueprint descriptors. For installing the
bundles, we use the features framework of Karaf. More specifically, we
generate a feature repository file, add the feature repository, install the
feature, remove the feature repository, and then delete the generated
feature repository file.
This worked well in Karaf 2.4.0, but if we do this in Karaf 4.0, the first
feature install succeeds, but a subsequent feature install yields the
following exception :

org.osgi.service.resolver.ResolutionException: Unable to resolve root:
missing requirement [root] osgi.identity;
osgi.identity=com.ikanalm.phase.echoparameters; type=karaf.feature;
version="[1.0.0,1.0.0]";
filter:="(&(osgi.identity=com.ikanalm.phase.echoparameters)(type=karaf.feature)(version>=1.0.0)(version<=1.0.0))"
	at
org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)[8:org.apache.karaf.features.core:4.0.7]
	at
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:235)[8:org.apache.karaf.features.core:4.0.7]
	at
org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:158)[8:org.apache.karaf.features.core:4.0.7]
	at
org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:216)[8:org.apache.karaf.features.core:4.0.7]
	at
org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[8:org.apache.karaf.features.core:4.0.7]
	at
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176)[8:org.apache.karaf.features.core:4.0.7]
	at
org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)[8:org.apache.karaf.features.core:4.0.7]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_60]
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_60]
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_60]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_60]

The bundle com.ikanalm.phase.echoparameters, version 1.0.0 is the one that
was installed using the generated feature repository file, which looks like
this :
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1"
name="com.ikanalm.phase.echoparameters1.0.0_1481545020697">
<feature name="com.ikanalm.phase.echoparameters" version="1.0.0">
<bundle>file://SOMEPATH/com.ikanalm.phase.echoparameters-1.0.0.jar</bundle>
</feature>
</features>

The feature doesn't show up when I do "feature:list -i", and the feature
repository isn't listed when I do "feature:repo-list". The bundle, however,
is still installed, so our application is able to use it.

Unfortunately, the feature is still listed in the requirements list of the
“root” instance :
karaf@root()> requirement-list
Region | Requirement
---------------------------------------------------------------
root   | feature:com.ikanalm.phase.echoparameters/[1.0.0,1.0.0]

When I do a “requirement-remove” on the feature, the feature is uninstalled,
and after that I can again install other features without the exception
popping up, but regrettably, the bundle is also uninstalled, so that doesn't
really help us.

Is there a way to remove a requirement on an instance without uninstalling
the feature or the bundle ? Or is the removal of the feature repository a
bad idea, and are we wrong to use the feature framework merely as a “vessel”
to get our bundles installed ?

Note again that this worked fine in Karaf 2.4.0.

Thanks,
Frank 'S Jegers.




--
View this message in context: http://karaf.922171.n3.nabble.com/Problems-after-removing-a-feature-repository-in-Karaf-4-0-tp4048979.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Problems after removing a feature repository in Karaf 4.0

Posted by Frank_S <fr...@ikan.be>.
The features are installed programmatically, by a separate "installer"
bundle. The karaf feature repo file is generated and saved in the persistent
storage area of that installer bundle. 
In our application, it's possible that a bundle with the same name and
version, but with different content gets re-installed. Currently, this is
not a problem, since we find the bundle, uninstall it, and re-install it
using feature:install and a “disposable” feature repository.

If we can't remove the feature repo, then if we need to reinstall a bundle,
we need to find the feature repo that was used to install it, and remove
that repo. If we wouldn't, then we would have 2 feature repos which contain
the same feature, which doesn't seem like a good idea. While this is not
impossible, it's more complicated than our current solution.

The point is that we don't really “need” a persistent feature repository, we
can easily regenerate the feature repository file when we need to reinstall
a bundle. A system that can regenerate data is usually simpler than a system
that needs to keep track of that data, making sure it stays in synch, is
backed up, doesn't get removed etc...

Using Karaf features to install bundles is very convenient for us. We have
URLStreamHandlers in place to handle file:, ftp:, and scp: protocols, which
means we can easily install bundles from remote locations.

The bundles that need to be installed are very light-weight, they are not
much more than a wrapper around an Ant script, with a blueprint descriptor
that registers it as an OSGi service. This allows us to run a reusable,
versioned Ant script on a remote system.While this Ant script is in
development, it will be repackaged into a bundle and redeployed to the
remote systems. Hence the need to re-install a bundle with the same name and
version.

I can see the need for tighter rules on features, certainly for
consistency’s sake, but we were happier with the more “relaxed” approach. I
don't have enough knowledge of Karaf or OSGi to propose a solution, but I
hope to make the case to allow less strict rules in certain cases.

Thank you very much for your swift reply,
Frank 'S Jegers.




--
View this message in context: http://karaf.922171.n3.nabble.com/Problems-after-removing-a-feature-repository-in-Karaf-4-0-tp4048979p4048988.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Problems after removing a feature repository in Karaf 4.0

Posted by Guillaume Nodet <gn...@apache.org>.
2016-12-12 15:16 GMT+01:00 Frank_S <fr...@ikan.be>:

> Hi,
>
> we run our application in Karaf. It has a pluggable architecture in the
> sense that extra bundles get installed that perform certain services. The
> services are defined using Blueprint descriptors. For installing the
> bundles, we use the features framework of Karaf. More specifically, we
> generate a feature repository file, add the feature repository, install the
> feature, remove the feature repository, and then delete the generated
> feature repository file.
> This worked well in Karaf 2.4.0, but if we do this in Karaf 4.0, the first
> feature install succeeds, but a subsequent feature install yields the
> following exception :
>
> org.osgi.service.resolver.ResolutionException: Unable to resolve root:
> missing requirement [root] osgi.identity;
> osgi.identity=com.ikanalm.phase.echoparameters; type=karaf.feature;
> version="[1.0.0,1.0.0]";
> filter:="(&(osgi.identity=com.ikanalm.phase.echoparameters)(
> type=karaf.feature)(version>=1.0.0)(version<=1.0.0))"
>         at
> org.apache.felix.resolver.ResolutionError.toException(
> ResolutionError.java:42)[8:org.apache.karaf.features.core:4.0.7]
>         at
> org.apache.felix.resolver.ResolverImpl.resolve(
> ResolverImpl.java:235)[8:org.apache.karaf.features.core:4.0.7]
>         at
> org.apache.felix.resolver.ResolverImpl.resolve(
> ResolverImpl.java:158)[8:org.apache.karaf.features.core:4.0.7]
>         at
> org.apache.karaf.features.internal.region.SubsystemResolver.resolve(
> SubsystemResolver.java:216)[8:org.apache.karaf.features.core:4.0.7]
>         at
> org.apache.karaf.features.internal.service.Deployer.
> deploy(Deployer.java:263)[8:org.apache.karaf.features.core:4.0.7]
>         at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.
> doProvision(FeaturesServiceImpl.java:1176)[8:org.apache.karaf.features.
> core:4.0.7]
>         at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(
> FeaturesServiceImpl.java:1074)[8:org.apache.karaf.features.core:4.0.7]
>         at java.util.concurrent.FutureTask.run(FutureTask.
> java:266)[:1.8.0_60]
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)[:1.8.0_60]
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)[:1.8.0_60]
>         at java.lang.Thread.run(Thread.java:745)[:1.8.0_60]
>
> The bundle com.ikanalm.phase.echoparameters, version 1.0.0 is the one that
> was installed using the generated feature repository file, which looks like
> this :
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1"
> name="com.ikanalm.phase.echoparameters1.0.0_1481545020697">
> <feature name="com.ikanalm.phase.echoparameters" version="1.0.0">
> <bundle>file://SOMEPATH/com.ikanalm.phase.echoparameters-
> 1.0.0.jar</bundle>
> </feature>
> </features>
>
> The feature doesn't show up when I do "feature:list -i", and the feature
> repository isn't listed when I do "feature:repo-list". The bundle, however,
> is still installed, so our application is able to use it.
>
> Unfortunately, the feature is still listed in the requirements list of the
> “root” instance :
> karaf@root()> requirement-list
> Region | Requirement
> ---------------------------------------------------------------
> root   | feature:com.ikanalm.phase.echoparameters/[1.0.0,1.0.0]
>
> When I do a “requirement-remove” on the feature, the feature is
> uninstalled,
> and after that I can again install other features without the exception
> popping up, but regrettably, the bundle is also uninstalled, so that
> doesn't
> really help us.
>
> Is there a way to remove a requirement on an instance without uninstalling
> the feature or the bundle ? Or is the removal of the feature repository a
> bad idea, and are we wrong to use the feature framework merely as a
> “vessel”
> to get our bundles installed ?
>

You shouldn't really remove a repository if you haven't uninstalled the
features in that repository.  There's an additional check in 4.1 which
forbids you to do that (see https://issues.apache.org/jira/browse/KARAF-4060
).

And if you uninstall the feature, the bundles will be uninstalled if they
are not needed anymore.

The reason is that the Karaf 4 features service considers the set of
requirements and computes a set of bundles that need to be installed.  If
you remove a requirement on the feature, the bundle does not need to be
installed anymore.  And if you remove the repository, the requirement on
the feature can't be satisfied anymore.

There's no easy workaround for this specific problem: there's definitely no
way to keep a feature installed and remove the corresponding repository.
Why do you see keeping the repository as a problem ?



>
> Note again that this worked fine in Karaf 2.4.0.
>
> Thanks,
> Frank 'S Jegers.
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/Problems-after-removing-a-feature-repository-in-Karaf-4-
> 0-tp4048979.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
------------------------
Guillaume Nodet
------------------------
Red Hat, Open Source Integration

Email: gnodet@redhat.com
Web: http://fusesource.com
Blog: http://gnodet.blogspot.com/

Re: Problems after removing a feature repository in Karaf 4.0

Posted by Christian Schneider <ch...@die-schneider.net>.
What you do sounds very strange.

Can you explain why you first install the repo and feature and then 
remove the repo?
Why don't you simply leave it there?

If you want to cleanly uninstall a feature and repo use 
feature:uninstall and feature:repo-remove.

Christian

On 12.12.2016 15:16, Frank_S wrote:
> Hi,
>
> we run our application in Karaf. It has a pluggable architecture in the
> sense that extra bundles get installed that perform certain services. The
> services are defined using Blueprint descriptors. For installing the
> bundles, we use the features framework of Karaf. More specifically, we
> generate a feature repository file, add the feature repository, install the
> feature, remove the feature repository, and then delete the generated
> feature repository file.
> This worked well in Karaf 2.4.0, but if we do this in Karaf 4.0, the first
> feature install succeeds, but a subsequent feature install yields the
> following exception :
>
> org.osgi.service.resolver.ResolutionException: Unable to resolve root:
> missing requirement [root] osgi.identity;
> osgi.identity=com.ikanalm.phase.echoparameters; type=karaf.feature;
> version="[1.0.0,1.0.0]";
> filter:="(&(osgi.identity=com.ikanalm.phase.echoparameters)(type=karaf.feature)(version>=1.0.0)(version<=1.0.0))"
> 	at
> org.apache.felix.resolver.ResolutionError.toException(ResolutionError.java:42)[8:org.apache.karaf.features.core:4.0.7]
> 	at
> org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:235)[8:org.apache.karaf.features.core:4.0.7]
> 	at
> org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:158)[8:org.apache.karaf.features.core:4.0.7]
> 	at
> org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:216)[8:org.apache.karaf.features.core:4.0.7]
> 	at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[8:org.apache.karaf.features.core:4.0.7]
> 	at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1176)[8:org.apache.karaf.features.core:4.0.7]
> 	at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:1074)[8:org.apache.karaf.features.core:4.0.7]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_60]
> 	at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_60]
> 	at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_60]
> 	at java.lang.Thread.run(Thread.java:745)[:1.8.0_60]
>
> The bundle com.ikanalm.phase.echoparameters, version 1.0.0 is the one that
> was installed using the generated feature repository file, which looks like
> this :
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1"
> name="com.ikanalm.phase.echoparameters1.0.0_1481545020697">
> <feature name="com.ikanalm.phase.echoparameters" version="1.0.0">
> <bundle>file://SOMEPATH/com.ikanalm.phase.echoparameters-1.0.0.jar</bundle>
> </feature>
> </features>
>
> The feature doesn't show up when I do "feature:list -i", and the feature
> repository isn't listed when I do "feature:repo-list". The bundle, however,
> is still installed, so our application is able to use it.
>
> Unfortunately, the feature is still listed in the requirements list of the
> \u201croot\u201d instance :
> karaf@root()> requirement-list
> Region | Requirement
> ---------------------------------------------------------------
> root   | feature:com.ikanalm.phase.echoparameters/[1.0.0,1.0.0]
>
> When I do a \u201crequirement-remove\u201d on the feature, the feature is uninstalled,
> and after that I can again install other features without the exception
> popping up, but regrettably, the bundle is also uninstalled, so that doesn't
> really help us.
>
> Is there a way to remove a requirement on an instance without uninstalling
> the feature or the bundle ? Or is the removal of the feature repository a
> bad idea, and are we wrong to use the feature framework merely as a \u201cvessel\u201d
> to get our bundles installed ?
>
> Note again that this worked fine in Karaf 2.4.0.
>
> Thanks,
> Frank 'S Jegers.
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Problems-after-removing-a-feature-repository-in-Karaf-4-0-tp4048979.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com