Cannot get HttpContext trough BundleContext in AEM 6.4
Hi!
I am working on migrating some bundles from AEM 6.2 to 6.4 and I ran into the following issue:
I have an Activator.java in a bundle with the following code:
@Override
public synchronized void start(final BundleContext bc) throws Exception {
myBundleContext= bc
private ServiceTracker<HttpService, HttpService> tracker = new ServiceTracker<HttpService, HttpService>(myBundleContext, HttpService.class, null) {
@Override
public HttpService addingService(ServiceReference<HttpService> sRef) {
ServiceReference<HttpContext> httpSRef = bundleContext.getServiceReference(HttpContext.class);
HttpContext hc = bundleContext.getService(httpSRef);
//some more code here working with the hc object...
}
}
}
When I start the bundle and run this code in AEM 6.2, I can successfully retrieve the HttpContext.class serviceReference and then get the HttpContext service, but when I run the exact same code in AEM 6.4 I get a null reference when trying to retrieve the HttpContext.class serviceReference.
I am aware that this kind of thing (using an activator and getting the HttpContext serviceReference) are not that common to do. I have already googled the problem for quite a while, read all kind of forums and threads but no luck yet.
I also checked that the service name and class are still the same in 6.2 and 6.4 and also the getServiceReference(Class) method is not deprecated in 6.4
So I'm starting to suspect that for some reason the HttpContext is not available in 6.4 as it was in 6.2. Not sure if it's something that was done intentionally or if it's a bug
Any help on this would be very appreciated!
Thanks!!