4

Karaf 4.0.3

I have the following pseudo-feature:

<features name="my-feature" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0">
<feature name="C" version="${project.version}" start-level="25" install="auto">
    <bundle start-level="25">...BundleC1...</bundle>
</feature>

<feature name="A" version="${project.version}" start-level="30" install="auto">
    <feature prerequisite="true">C</feature>
    <bundle start-level="30">...BundleA1...</bundle>
</feature>

<feature name="B" version="${project.version}" start-level="35" install="auto">
    <feature prerequisite="true">C</feature>
    <bundle start-level="35">...BundleB1...</bundle>
</feature>

C is independant
A depends on C
B depends on C

In this example the bundle 'BundleB1' imports wrong major version of 'BundleC1' and we get the "missing requirement" error (as expected). However if I log into the karaf console and run 'feature:list' I will see that C is Started, A is Uninstalled and B is Uninstalled.

I expect A to be Started since it only has dependencies to C. A will start fine if I comment out the entire C feature or if I afterwards run feature:install A

If I put each of these three features in seperate feature.xml files I get the expected outcome of C+A as Started and B as Uninstalled.

What am I doing wrong?

Am I misunderstanding how the prerequisite attribute works? As a sidenote, if I skip the prerequisite attribute all together then no feature will get installed whatsover...

Simon Forsberg
  • 13,086
  • 10
  • 64
  • 108
stromvap
  • 213
  • 1
  • 7

1 Answers1

4

This is the expected behavior in Karaf 4 : Karaf creates one subsystem with all the features to install. This subsystem is resolved in one pass : either it success or it fails, as a whole.

The prerequisite attribute tells Karaf to install this feature in an independent subsystem : All the bundles are installed and started before trying to resolve the others features.

In your case :

  • C is installed/started ;
  • A+B is resolved, but it fails
Jérémie B
  • 10,611
  • 1
  • 26
  • 43
  • Ok, so the only way to get C+A to be Installed/Started and B to be Uninstalled/Failed is to extract each sub-feature into seperate feature.xml files? That way they will be installed in their own Context/Process? – stromvap Jul 05 '16 at 06:51
  • It depends how you install your features. If you use the deploy folder, then yes, you have to split them in different files, il you use the file `org.apache.karaf.features.cfg`, then you can specifiy which feature to install, and create groups with parenthesis, like : (C), (A), (B) – Jérémie B Jul 05 '16 at 07:03
  • 3
    Could you please elaborate on how to use `org.apache.karaf.features.cfg ` and "groups" or point me in the direction of some documentation? I find the karaf documentation quite lacking and it's hard to find relevant examples. – stromvap Jul 05 '16 at 08:14
  • @JérémieB Is this information about the relationship between feature files and subsystems documented anywhere (specifically)? – Jonathan Komar Aug 15 '19 at 19:28