We are trying to integrate a web application running on Apache Tomcat 8.5.3 with Apache ServiceMix 7.0.1 using Apache Felix bridge (org.apache.felix.http.bridge-4.0.0.jar). All the steps listed here are done http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html
But we are now getting a 503 Service unavailable error.
On debugging, we identified that this error is thrown via org.apache.felix.http.proxy.ProxyServlet (org.apache.felix.http.proxy-3.0.2.jar)
final HttpServlet dispatcher = this.tracker.getDispatcher();
if (dispatcher != null) {
final HttpServletRequest r = (this.servletContext == null ? req : new BridgeHttpServletRequest(req, this.servletContext));
dispatcher.service(r, res);
} else {
res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
}
Now the reason 'dispatcher' is null because in tracker (org.apache.felix.http.proxy.DispatcherTracker), it is not getting set.
@Override
public Object addingService(ServiceReference ref)
{
Object service = super.addingService(ref);
if (service instanceof HttpServlet) {
setDispatcher((HttpServlet)service);
}
return service;
}
So (service instanceof HttpServlet) is returning as false. We traced the origin of "service" and found it to be in org.apache.felix.http.bridge.jar class - org.apache.felix.http.bridge.internal.BridgeActivator 'service' is instantiated as an anonymous child class of HttpServlet so instanceof should have been true.
One observation - I noticed that the classloaders for these 2 classes is different.
Classloader for 'service' is org.eclipse.osgi.internal.loader.EquinoxClassLoader (since it is loaded inside an OSGI bundle) Classloader for HttpServlet is java.net.URLClassLoader
Could this be the reason why instanceof is returning as false? If so, what can be the solution to address this.
Any help is highly appreciated. Thanks in advance.