How do I deploy a feature with configuration file?
Environment
- Fuse ESB Enterprise 7.1
Issue
I am deploying configuration with feature, but the configuration file is not created in etc/ as I would expect.
For example, create a new feature:
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
<feature name="test-config-admin" version="1.0.0">
<config name="fusesource.foo">
hello = world
year = 2013
month = 2
</config>
</feature>
</features>
Add the feature and install it:
features:addurl file:<location>/feat.xml
features:install test-config-admin
config:list shows the expected results but there is no file in the ./etc directory:
Pid: fusesource.foo
BundleLocation: null
Properties:
service.pid = fusesource.foo
hello = world
year = 2013
org.apache.karaf.features.configKey = fusesource.foo
month = 2
Is this expected behaviour?
Resolution
The Configuration Admin Service is stored in memory so this is working as expected. You can over-ride it by manually creating a file, i.e:
wildflower:etc sjavurek$ cat fusesource.foo.cfg
greeting=hola
In this case, the file over-rides the contents of the in memory version:
FuseESB:karaf@root> config:list "(service.pid=fusesource.foo)"
----------------------------------------------------------------
Pid: fusesource.foo
BundleLocation: null
Properties:
service.pid = fusesource.foo
felix.fileinstall.filename = file:/Users/sjavurek/Fuse/Enterprise/7.1/fuse-esb-7.1.0.fuse-047/etc/fusesource.foo.cfg
greeting = hola
Alternatively, you may also create the file from the feature configuration:
<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
<feature name="test-config-file" version="1.0.0" resolver="(obr)">
<configfile finalname="/etc/test_properties.cfg">mvn:test/config-test/1.0.0-SNAPSHOT/cfg</configfile>
</feature>
<feature name="test-config" version="1.0.0" resolver="(obr)">
<bundle>mvn:test/config-test/1.0.0-SNAPSHOT</bundle>
</feature>
</features>
In this case, you'll have two features. When you install, features:install test-config-file, the configuration file will be created and accessible by the bundle. Note, this solution is a small work around to ENTESB-593 which prevents the configuration file from being picked when using the "configfile" tag:
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">\
<feature name="test-config" version="1.0.0" resolver="(obr)">
<configfile finalname="/etc/test_properties.cfg">mvn:test/config-test/1.0.0-SNAPSHOT/cfg</configfile>
<bundle>mvn:test/config-test/1.0.0-SNAPSHOT</bundle>
</feature>
</features>
For more information, please contact support.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
