Hi,

I am trying to run a JAX-RS service in Tomcat, so I use 
CXFNonSpringJaxrsServlet.

I test it by starting a Jetty server (using 
org.mortbay.jetty:jetty-maven-plugin, which starts the jetty server at 
http://localhost:8080/test) and running a test class which sends GETs, with the 
following results:

[1] http://localhost:8080/test/foo?_wadl
(returns the WADL)

[2] http://localhost:8080/test/foo/myKeyType/myKeyValue
WARN  transport.servlet.ServletController  - Can't find the the request for 
http://localhost:8080/test/rpg/foo/myKeyType/myKeyValue's Observer
(reports the above warning, then fails with HTTP 404)

The docs 
(http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAXRSservicesincontainerwithoutSpring)
 suggest I might need to define a provider class or an application class, but 
the examples in Apache's SVN suggest this is not necessary.

I think it is either (a) failing to load the necessary CXF libs, or (b) failing 
to resolve the method in my resource class.

So please tell me, what am I missing? Do I need to define a dedicated 
provider/application class? Or load CXF resources via Spring? Or is it 
something else entirely?

I can provide a test case if necessary, but for now here are the relevant 
snippets...

My resource class looks like this:

@Path("/foo")
public class MyRestService {

    public MyRestService() {
    }

    @GET
    @Path("/{keyType}/{keyValue}")
    public MyXmlMessage doSomething(
            @PathParam("keyType") String keyType,
            @PathParam("keyValue") String keyValue,
            @Context HttpServletResponse httpResponse)
            throws Exception {
        // set the HTTP status code using HttpServletResponse
        // do other stuff and return an object of type MyXmlMessage
    }
}

My web.xml looks like this:

<web-app version="2.5"
  metadata-complete="true"
  xmlns="http://java.sun.com/xml/ns/javaee";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
  <display-name>my-rest-server</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/rpg-rest-service-context.xml</param-value>
  </context-param>
  <listener>
    
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>CXFServlet</servlet-name>
    
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
    <init-param>
      <param-name>jaxrs.serviceClasses</param-name>
      <param-value>com.foo.MyRestService</param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.address</param-name>
      <param-value>/foo</param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.extensions</param-name>
      <param-value>
        xml=application/xml
        json=application/json
      </param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.schemaLocations</param-name>
      <param-value>classpath:schemas/MyXmlMessage.xsd</param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.languages</param-name>
      <param-value>en=en-gb</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/foo/*</url-pattern>
  </servlet-mapping>
</web-app>

My Spring XML contains nothing relevant, just a properties placeholder and a 
bean that injects properties into running classes.

Regards,
Paul

STRICTLY PRIVATE, CONFIDENTIAL AND PRIVILEGED COMMUNICATION.

This message (including attachments) may contain information that is
privileged, confidential or protected from disclosure. They are intended
solely for the use of the intended recipient. If you are not the
intended recipient, you are hereby notified that dissemination,
disclosure, copying, distribution, printing, transmission or use of this
message or any information contained in it is strictly prohibited. If
you have received this message from NewBay Software in error, please
immediately notify the sender by reply email and delete this message
from your computer. The content of this e-mail, and any files
transmitted with it, may have been changed or altered without the
consent of the author. Although we have taken steps to ensure that this
email and attachments are free from any virus, we advise that in keeping
with good computing practice the recipient should ensure they are
actually virus free.

Reply via email to