Scott Lewis
2018-10-20 21:31:55 UTC
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
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