Programatically push configuration into OSGi ConfigurationAdmin

Yesterday I lost half an hour when I struggled to push a configuration into OSGi ConfigurationAdmin. The was in fact called, but the Dictionary of properties was always null. It turns out, I forgot that one has to lookup the not just by service PID, but also by (bundle) location. And since the location was not matching, the configuration was not a valid config for the bundle that implements the ManagedService. Below is how one correctly configures the ManagedService registered with PID “my.ManagedService.Service.Pid” ( Notice the “?” location wildcard!

String servicePID = "my.ManagedService.Service.Pid";
Configuration configuration = 
    cm.getConfiguration(servicePID, <strong><span style="color: #ff0000;">"?"</span></strong>);
Dictionary<String, Object> properties = 
if (properties == null) {
    properties = new Hashtable<String, Object>();
properties.put("someKey", "someValue");

Want to comment? Send me an email to blog-comments-2018 at lemmster d.t de and I'll paste it here (I won't publish your address). Why don't you use an external comment service like disqus, you ask? Well, I like to keep this site under my control, comments included. You can use markdown to format your comment.