Hi Thomas,

I think this fix is not correct. If the http service can only be found with .open(true) it means that the package the service implements and the package cxf imports are different.

I assume you simply forgot one step of the bridge installation guide:
http://felix.apache.org/documentation/subprojects/apache-felix-http-service.html#using-the-servlet-bridge

be sure to add |javax.servlet;javax.servlet.http;version=2.6| to OSGi system packages (|org.osgi.framework.system.packages|);

Christian

On 13.07.2015 17:07, Thomas Konstantinides wrote:
Hi everyone,

I am having some problems with CXF HTTP Transport in an OSGi environment using 
Apache Felix as OSGi Framwork.

I'm using the Felix Http Bridge to start Felix within a .war web application 
which runs in Tomcat. The problem is, that the ServiceTracker which is set up 
in org.apache.cxf.transport.http.osgi.HTTPTransportActivator does not find the 
HttpService which is provided by the bundle org.apache.felix.http.bridge.

I tried a small change in the CXF code, changing line 64 in 
HTTPTransportActivator to

httpServiceTracker.open(true);

With this change the HttpService is recognized by the ServiceTracker and the 
CXF Servlet is setup correctly.

I did a bit more debugging to get to the root cause of this behavior and found, 
that the problem is caused when the method

ServiceRegistrationImpl.isAssignableTo()

is called in the process of opening the ServiceTracker and getting the list of already available 
services for the interface HttpService (ServiceTracker. getInitialReferences() -> 
context.getServiceReferences). The Implementation of Felix' HttpService 
(org.apache.felix.http.base.internal.service.HttpServiceImpl) implements not only HttpService but also 
ExtHttpService. And when asking ServiceRegistrationImpl.isAssignableTo() with the parameters 
requester: "org.apache.cxf.cxf-rt-transports-http [27]" and className: 
"org.apache.felix.http.api.ExtHttpService" it returns false.

Now a simple fix is given by what I already wrote above: Changing 
httpServiceTracker.open() to httpServiceTracker.open(true); in 
HTTPTransportActivator

So I'd like to ask two questions:
1. Does anyone have a better solution on how to get this scenario working?
2. If not: Could this fix be inserted into the CXF code to enable us (and 
others which might have similar problems) to use the offical .jar and not a 
self-built one?

Thanks for your comments,
Thomas



--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Reply via email to