On 10/30/2018 12:53 PM, David Karlsen wrote:
I register several jaxrsServerFactoryBean beans with the same but - under
different addresses - which works fine

So that I understand:  you register multiple beans with the same instance of CXFNonSpringServlet...with different aliases (e.g. '/foo' and '/bar')?   I also assume you are not using the OSGi HttpService to register multiple servlet instances, correct?

If at all possible, I would like to use multiple instances of CXFNonSpringServlet with HttpService, and not have them conflict.

Scott


Den tir. 30. okt. 2018 kl. 16:56 skrev Scott Lewis <sle...@composent.com>:

Separate bus instances are created for the CXFNonSpringServlets init,
but what apparently blows up is the create/use/start of more than one
org.apache.cxf.endpoint.ServerImpl instance at:  at
org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:123).

Any insights on how to avoid/work around this?

Scott

   On 10/21/2018 9:53 AM, Scott Lewis wrote:
On 10/21/2018 2:38 AM, David Karlsen wrote:
If you have separate CxfBus'es per servlet it should work AFAIK.
It seems that by default in the superclass
org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(ServletConfig)
the loadBus method is called during init, and that's implemented as:

     protected void loadBus(ServletConfig sc) {
         this.bus = BusFactory.newInstance().createBus();
     }

This seems to be a separate Bus instance (createBus())...apparently of
the same type.

So the two servlet instances do have separate Bus instances, but I
still get the error described.

Thanksinadvance,

Scott

Den lør. 20. okt. 2018 kl. 23:32 skrev Scott Lewis
<sle...@composent.com>:

Hi,

Using OSGi HttpService, if I register more than one instance of
CXFNonSpringJaxrsServlet...i.e. at different aliases...then I get an
exception.  For example if I have two aliases

'/foo' -> instance 1 of CXFNonSpringJaxrsServlet

'/bar' -> instance 2 of CXFNonSpringJaxrsServlet

on the second call to httpService.registerServlet I get exception and
stack trace below.

Is there a way to create/configure/register multiple
CXFNonSpringJaxrsServlet instances...and/or the underlying
JAXRSServerFactoryBean so that they don't conflict in this manner?  Or
is there some other cxf jaxrs servlet/bean classes that would allow
this?

Thanksinadvance,

Scott

org.apache.cxf.service.factory.ServiceConstructionException
       at


org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:219)

       at


org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet.createServerFromApplication(CXFNonSpringJaxrsServlet.java:546)

       at


org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet.init(CXFNonSpringJaxrsServlet.java:115)

       at


org.eclipse.equinox.http.servlet.internal.HttpServiceRuntimeImpl$LegacyServlet.init(HttpServiceRuntimeImpl.java:1206)

       at


org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.init(EndpointRegistration.java:94)

       at


org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddServletRegistration(ContextController.java:596)

       at


org.eclipse.equinox.http.servlet.internal.context.ContextController.addServletRegistration(ContextController.java:450)

       at


org.eclipse.equinox.http.servlet.internal.customizer.ContextServletTrackerCustomizer.addingService(ContextServletTrackerCustomizer.java:55)

       at


org.eclipse.equinox.http.servlet.internal.customizer.ContextServletTrackerCustomizer.addingService(ContextServletTrackerCustomizer.java:1)

       at


org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)

       at


org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)

       at

org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
       at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
       at


org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)

       at


org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)

       at


org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920)

       at


org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)

       at


org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)

       at


org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)

       at


org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)

       at


org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)

       at


org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)

       at


org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469)

       at


org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487)

       at


org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004)

       at


org.eclipse.equinox.http.servlet.internal.HttpServiceRuntimeImpl.registerHttpServiceServlet(HttpServiceRuntimeImpl.java:722)

       at


org.eclipse.equinox.http.servlet.internal.HttpServiceImpl$3.run(HttpServiceImpl.java:148)

       at


org.eclipse.equinox.http.servlet.internal.HttpServiceImpl$3.run(HttpServiceImpl.java:1)

       at java.security.AccessController.doPrivileged(Native Method)
       at


org.eclipse.equinox.http.servlet.internal.HttpServiceImpl.registerServlet(HttpServiceImpl.java:145)

<stack deleted>
Caused by: org.apache.cxf.service.factory.ServiceConstructionException:
There is an endpoint already running on /.
       at


org.apache.cxf.jaxrs.JAXRSBindingFactory.addListener(JAXRSBindingFactory.java:86)

       at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:123)
       at


org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:206)

       ... 84 more






Reply via email to