Search code examples
apache-camelosgikarafblueprint

Karaf : feature:install restarts previous bundles


I'm facing an irritating behavior from my karaf server: Title says it all, installed bundles get restarted when I use a feature: install command.

* Project context *

  • Most of the bundles I deal with are camel routes, the other ones are common tools, shared by the routes.

  • As a result, I have a 2 level project: a common part that is installed first, and the camel routes that all depends on the common part (dependent on Maven point of view).

* Scenario *

  • start a fresh instance of karaf
  • install the common features
  • install a camel route feature: no troubles so far
  • install a second camel route feature: the bundles from the previously installed feature will restart.

* Breakthrough made *

All the bundles declared a common config file, with the option "update-strategy=reload". This means that karaf would notify each bundle of any modification of this file, and the bundle would restart to take it into account.

As a matter of fact, when I installed a new bundle with a dependency on this file, it would be read in order to initialize the bundle's properties, and karaf considered it to be a file modification. Therefore, installing a new bundle made all the others restart.

As you expect, I dealt with that problem by removing the update-strategy option, and most of my features are now clean.

* Leftovers *

BUT, some of them still holds the bug: Installing any of those troublesome features will have all the other installed features restart. This is a ONE-WAY problem, installing a clean bundle will not have the troublesome ones restart.

I checked anyway, but no other config file could be responsible for that.

Any help or advice would be appreciated, I can also provide anonymized examples of any file that would help you understand, like an osgi-context or a feature's pom.xml

One last thing: my features regroup around 50 bundles each, therefore I can barely understand the karaf logs, and I can't pinpoint which bundle is restarted first.

Thanks for your time and attention!


Solution

  • I think there are some misconceptions in what you describe.

    update-strategy=reload does not cause a bundle to reload. It causes a blueprint context to reload.

    You should also not share the some config between bundles it is known to mess up you deployments.

    There are also other reasons why a bundle may restart. A karaf feature install tries to provide the optimal set of bundles that is needed overall in karaf to satisfy the set of currently installed features. A typical case is that you first install feature with a bundle containing an optional package import. At this moment it can not provide the package. Then you install a second feature that provides an exporter of the package. Now the optional dependency of the bundle can be satisfied and the bundle will be restarted by karaf. You can look into such cases by using feature:install -v . This will show you which bundles are restarted and also why. So maybe this can help you to debug why the restart happens.