Hi Carlos,

thanks, I already create a bus per servlet (it's what I thought it
allows isolation), but doesn't seem to work.

Let me compare with what we do in JAXRS Whiteboard.

Thanks,
Regards
JB

On 15/10/2019 09:24, Carlos Sierra Andrés wrote:
> Hi there,
> 
> you can have a look at the aries jax-rs whiteboard, we create one
> CXFNonSpringServlet per application, and they are all deployed on "/" of
> their respective ServletContext.
> 
> https://github.com/apache/aries-jax-rs-whiteboard/blob/master/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
> 
> 
> I would say we "only" create a bus per servlet, nothing more, but feel
> free to have a look.
> 
> I hope this helps.
> 
> Carlos.
> 
> El 15/10/19 a las 7:44, Jean-Baptiste Onofré escribió:
>> Hi,
>>
>> I have extended CXFNonSpringServlet two times:
>>
>> public class MyServlet1 extends CXFNonSpringServlet {
>>
>>    @Override
>>    public void init(ServletConfig config) throws ServletException {
>>      super.init(config);
>>      JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
>>      bean.setAddress("/");
>>      bean.setBus(getBus());
>>      bean.setProvider(new JacksonJsonProvider());
>>      bean.setServiceBean(new MyApi());
>>      bean.create();
>>    }
>>
>> }
>>
>> same with MyServlet2.
>>
>> MyServlet1 has /myservlet1 as alias, MyServlet2 has /myservlet2.
>> Note that I would like to use "/" for JAXRS server address as it's based
>> directly on the servlet alias (context).
>>
>> When I start the first servlet (let say MyServlet1), it's OK. However
>> when I start the second one (let say MyServlet2, but the same happens if
>> I start MyServlet2 first and MyServlet1), it fails with:
>>
>> 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:128)
>> ~[?:?]
>>          at
>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:209)
>>
>> ~[?:?]
>>
>> So, even if I use two different servlets, it seems CXF has a shared
>> resource somewhere.
>>
>> Obviously if I have different address for JAXRS server it works, but
>> it's not that I want as I'm using two different servlets.
>>
>> I tried:
>> - to create a bus dedicated in each servlet
>> - to create a destination registry in each servlet
>> but it doesn't help.
>>
>> So, basically, my question is: is there a way to have completely
>> isolated CXFNonSpringServlet ?
>>
>> I gonna dig into CXF code today but if you already have some ideas, it
>> would be great.
>>
>> Thanks !
>> Regards
>> JB

-- 
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to