Hi Erwin,
simply use the address:
props.put("org.apache.cxf.ws.address", "/MyService");
and no context. This way each of your services can have its own path and
all will share the http service port.
Christian
2017-07-29 19:52 GMT+02:00 Erwin Hogeweg <[email protected]>:
> Hi,
>
> I have a couple of OSGi services which are available as remote OSGi
> service with CXF-DOSGi. The services are registered with the following
> props, and that all works fine:
>
> Dictionary<String, Object> props = new Hashtable<String, Object>();
> props.put("name", "MyServiceImpl");
> props.put("type", "internal");
> props.put("service.exported.interfaces", "*");
> props.put("service.exported.configs", "org.apache.cxf.ws");
> props.put("org.apache.cxf.ws.address", "http://" + serviceHost + ":" +
> servicePort + "/MyService");
> props.put("org.apache.cxf.ws.httpservice.context", "/MyService");
>
> However, I would like to use the port defined with
> org.osgi.service.http.port property as the service port. That doesn’t work
> though because CXF creates a new instance of JettyHttpDestination for
> every used port. This is from JettyHttpDesitination.java where servers for
> ea. port are created:
>
> protected void retrieveEngine()
> throws GeneralSecurityException,
> IOException {
> if (serverEngineFactory == null) {
> return;
> }
> engine =
> serverEngineFactory.retrieveJettyHTTPServerEngine(
> nurl.getPort());
> if (engine == null) {
> engine = serverEngineFactory.
> createJettyHTTPServerEngine(nurl.getHost(),
> nurl.getPort(), nurl.getProtocol());
> }
>
> And port 8088 is already claimed by the HttpService registered by CXF:
>
> g! services (objectClass=*HttpService)
> {org.osgi.service.http.HttpService, org.eclipse.equinox.http.
> servlet.ExtendedHttpService}={service.description=Equinox Jetty-based
> Http Service, service.vendor=Eclipse.org<http://Eclipse.org>,
> http.port=8088, service.id=64, service.bundleid=31, service.scope=bundle}
> "Registered by bundle:"
> org.eclipse.equinox.http.servlet_1.1.400.v20130418-1354
> [31]
> "Bundles using service"
> org.apache.cxf.cxf-rt-transports-http_3.1.6 [82]
> cxf-dosgi-ri-dsw-cxf_1.7.0 [138]
>
> The CXF-DOSGi documentation<http://cxf.apache.org/distributed-osgi-
> reference.html> says about the org.apache.cxf.ws.httpservice.contex:
> "When this property is specified, the OSGi HTTP Service is used to expose
> the service, rather than a dedicated Jetty HTTP Server. This property
> doesn't allow the specification of a port number, as this is provided by
> the HTTP Service. The Distributed OSGi distributions come with Pax-Web, for
> which configuration information can be found at
> http://wiki.ops4j.org/display/paxweb/Configuration, however other OSGi
> HTTP Service implementations are potentially configured differently.”
>
> When I try that, the service is bound to localhost:9000 instead of
> 0.0.0.0:8088, which seems to happen in org.apache.cxf.dosgi.dsw.
> handlers.PojoConfiguration.java:
>
> private String getPojoAddress(Map<String, Object> sd, Class<?> iClass)
> {
> String address = getClientAddress(sd);
> if (address != null) {
> return address;
> }
>
> // If the property is not of type string this will cause an
> ClassCastException which
> // will be propagated to the ExportRegistration exception property.
> Object port = sd.get(Constants.WS_PORT_PROPERTY);
> if (port == null) {
> port = "9000";
> }
>
> address = "http://localhost:" + port + "/" +
> iClass.getName().replace('.', '/');
> LOG.info("Using a default address: " + address);
> return address;
> }
>
> I am trying to understand what I am missing for a while now, and every now
> and again on a quiet Fri. afternoon (…) I take another stab at it, but I am
> not getting much further.
>
> FWIW… the CXF servlet IS registered under the port defined by
> org.osgi.service.http.port.
>
> This is all based on
> CXF: 3.1.6 and CXF-DOSGi: 1.7.0
> Java 8
> Eclipse Equinox 3.10.2
>
> I checked the release notes for 1.8.0 but didn’t see anything related to
> this issue.
>
> Any suggestions or pointers in the right directions would be greatly
> appreciated.
>
>
> Thanks,
>
> Erwin
> Erwin Hogeweg
> CTO
> 3690 Airport Road
> Boca Raton, FL 33431
> P. +1 (954) 556-6565
> M. +1 (561) 306-7395
> F. +1 (561) 948-2730
> [Seecago]<http://www.seecago.com>
>
--
--
Christian Schneider
http://www.liquid-reality.de
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>
Open Source Architect
http://www.talend.com
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>