@Reference service always null in BundleListener class
I am having issues trying to access a service of mine in a BundleListener. The service (LanguageService) works in different parts of my code outside of the BundleListener (for example my rest endpoints).
Activator:
public class Activator implements BundleActivator {
@Override
public void start(BundleContext bundleContext) throws Exception {
bundleContext.addBundleListener(new PlatformCoreBundleListener());
}
...
}
BundleListener:
@Component(immediate = true)
public class PlatformCoreBundleListener implements BundleListener {
private static final Logger LOG = LoggerFactory.getLogger("AsAdventure");
@Reference
private LanguageService languageService;
@Override
public void bundleChanged(BundleEvent bundleEvent) {
String symbolicName = bundleEvent.getBundle().getSymbolicName();
if (symbolicName.equalsIgnoreCase(BundleConstants.SYMBOLIC_AEM_PLATFORM_CORE_BUNDLE)) {
if (bundleEvent.getType() == BundleEvent.STARTED) {
LOG.info("[PlatformCoreBundleListener]: " + BundleConstants.SYMBOLIC_AEM_PLATFORM_CORE_BUNDLE + " has started.");
}
}
}
}
The languageService is always null even when I take a look at it in debug mode while the bundleEvent has a type of 'STARTED'.
What am I doing wrong? Thanks in advance!

