Trying to get a ServiceReference this way is setting yourself up for disaster. This code can't handle 99% of the cases of what happens in OSGi: the config admin might not be there, the config admin bundle is started after you, the config admin bundle is in another start level, the config admin bundle is stopped, and the config admin is updated. The core OSGi API is very powerful, and is used by much middleware, but should not ever be used for application code since it requires way to much understanding of the underlying model and is very error prone.
By far the easiest and most reliable solution is to use Declarative Services (DS) with the annotations:
@Component
public class MyClass implements MyService {
ConfigurationAdmin ca;
@Reference void setCA(ConfigurationAdmin ca) { this.ca = ca; }
public void doMyService() {
// ... you can safely use ca
}
}
And Gunnar might be right, maybe have not installed a Configuration Admin service in the first place. However, with your current snippet your code is going to blow up anyway at another time.