Skip to end of metadata
Go to start of metadata

In Karaf Tutorial Part 2 - Using the Configuration Admin Service we learned how to configure our bundles using simple configurations.

In this part we will learn how to use the Metatype Service and the Felix Webconsole to easily create and edit these configurations

Using the Webconsole to edit an untyped Configuration

So when we have the Karaf container from Part 2 running and the config present we can already use the Felix Webconsole to edit the configuration.

> features:install webconsole

Open your browser with http://localhost:8181/system/console/configMgr

You will see the list of configurations the config admin service knows about:

Untyped Configuration

So the first thing we want to see is the untyped configuration. To see this copy the ConfigApp.cfg file from the git sources to the etc dir of Karaf. It should now be listed in the above list. If you click edit you will see the following:

So you get a freeform text editor with the current config. You can edit and save the config.The config is changed in the config admin service and internally persisted but not written to the etc dir (in current Karaf version).

Now delete the file from etc again. The config will not be shown in the list anymore.

Typed configuration

Now we will take a look at typed configuration. The Felix Webconsole can create typed configurations and also show a nice Editor for them.

To enable this we need to create OSGi Metatype information in our bundle. To do this simply create a file in the directory OSGI-INF/metatype.

For our configapp example the following config will work:

 <?xml version="1.0" encoding="UTF-8"?>
<MetaData xmlns=""
     <OCD description="Configured Example Application" name="ConfigApp" id="ConfigApp">
         <AD name="Title" id="title" required="true" type="String" default="Default Title" description="Title for the Application"/>
     <Designate pid="ConfigApp">
         <Object ocdref="ConfigApp"/>

So this is just an xml file with the MetaType Namespace. The object class definition (OCD) Element represents a configuration.




Id to reference in the designate element


User friendly name for editors


Longer description for editors

The  attribute definition (AD) represents an attribute.




ID for programmatic retrieval of this attribute


User friendly name to show in editors


Longer description for editors


(true|no) Determines if this attribute has to be filled


(String | Long | Double | Float | Integer | Byte |Char |Boolean | Short)


Default value if the attribute is not yet present

You can also define the values to choose from.

See for more information about the OSGi MetaType Service.

The last thing to define is the Designate element which maps the object class defintion to a config admin pid.

Test the Typed Config

Now build the configapp project using mvn install and copy the configapp.jar to the deploy directory of Karaf. The Webconsole should now show the ConfigApp Element in the configurations tab even if no such config exists.

You can then click edit and should see the following screen:

So we get a nice form to edit our configuration and also get default values if we create a new config. A click on Save will create or update this config in the config admin service and out bundle will reflect the change.

To see a larger example you can edit the configuration of the felix fileinstall bundle which will show the following screen:


So we have learned how to edit typed and untyped configuration with the Felix Webconsole and how to define configuration metadata.

Back to Karaf Tutorials

1 Comment

  1. Current issues