I have a OSGi service that I'd like to inject in one of my bundles.
When I use @Inject it's always Null - and I don't understand why. Is it not
possible to use @Inject in a BundleActivator?
When I manually access the Service Registry (-> see start() method) it
works fine.
public class ClientActivator implements BundleActivator {
@Inject
IMyService service;
@Override
public void start(BundleContext context) throws Exception {
System.out.println(service); // -> Null
ServiceReference reference =
context.getServiceReference(IMyService.class.getName());
IMyService service = (IMyService) context.getService(reference);
System.out.println(service); // -> not Null
}
...
}