Hello,

I have quite basic questions about JAX-RS support in CXF (2.3.3) :

- If you look at servlet code and web.xml descriptor bellow, is it the good way 
to expose a REST ws (without using spring)
- How to remove "sf.setAddress("http://localhost:8080/";)" ? => I don't know 
what will be the port number of the app server where my webapp will be deployed
- How to remove useless <init-param> for serviceClasses without runtime 
exception

Thanks and regards,
Anthony



Servlet code:

public class MyServlet extends CXFNonSpringJaxrsServlet {

        public MyServlet() {
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setTransportId("http://cxf.apache.org/transports/http";);
        sf.setResourceClasses(MyResource.class);
        sf.setResourceProvider(MyResource.class, new 
SingletonResourceProvider(new MyResource()));
        sf.setAddress("http://localhost:8080/";);
        sf.create();
        }
}

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID" version="2.5">
  <servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>com .... MyServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
        <init-param>
                <param-name>jaxrs.serviceClasses</param-name>
                <param-value>com ... MyResource</param-value>
        </init-param>
  </servlet>
    
  <servlet-mapping>
    <servlet-name> MyServlet </servlet-name>
    <url-pattern>/MyResource/*</url-pattern>
  </servlet-mapping>
</web-app>

Reply via email to