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é
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to