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

final Object servlet = new HttpServlet()
{
    private static final long serialVersionUID = -5229577898597483605L;

    @Override
    public void destroy()
    {
        getHttpServiceController().unregister();
        dispatcherServlet.destroy();
        super.destroy();
    }

    @Override
    public void init(final ServletConfig config) throws ServletException
    {
        super.init(config);
        dispatcherServlet.init(config);
        getHttpServiceController().register(config.getServletContext(),
serviceRegProps);
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws
ServletException, IOException {
        dispatcherServlet.service(req, res);
    }
};
The instance 'servlet' is what is getting propagated into service above. As
you can see servlet is instantiated as an anonymous child class of
HttpServlet. But immediately after debugging at this point, if we check
(servlet instanceof HttpServlet), it returns false.

Need some inputs on why this would return false although its a direct child
of HttpServlet. We suspect it could be a classloader issue with Tomcat &
Karaf classloaders both probably loading the HttpServlet class but not sure
on that.

Any help is highly appreciated. Thanks in advance.



--
Sent from: 
http://apache-felix.18485.x6.nabble.com/Apache-Felix-Dev-f4846309.html

Reply via email to