karafblueprintproperty-placeholder

Karaf v4.0.8 : Multiple Blueprints cannot load configuration from same persistent-id


Update: It took a little time to realize for some reason but I see that configuration files are bundle PID specific and by trying to load the same cfg file in blueprint within two different bundles, I was creating a race condition. Make sure you use the cfg files in their target bundles only.

Note: The above applies only to blueprint bundles. If you do not depend on OSGI ConfigAdmin service to keep the bundles dynamically and want to use the cfg files from something like a Camel context, that should be fine.

I have 2 blueprints deployed through karaf 4.0.8 'deploy' folder. Both have the following common section:

    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
    http://camel.apache.org/schema/blueprint https://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

    <cm:property-placeholder id="common" persistent-id="common" update-strategy="reload" placeholder-prefix="$(" placeholder-suffix=")"/> 

    <cm:property-placeholder id="sqlcfg" persistent-id="12345" update-strategy="reload" placeholder-prefix="$[" placeholder-suffix="]">
    </cm:property-placeholder> 

I would like to load configuration common to both from 'common'. However, when they share the same persistentId and properties file from the 'etc' folder, the blueprint to be deployed second keeps loading and unloading. If I get them to load from different files - it all works.

Any ideas from the community why I have this behaviour? Thanks in advance.


Solution

  • In my experience, you either set a different persistent-id or set update-strategy="none". This will stop the second module from going into that loading/unloading loop.

    The downside is that you lose the auto refresh of the config file.