After years away from CXF and JAX-RS (and other related things), I'm going to
be building a small JAX-RS service using CXF and Spring.
I'm basing what I have so far on what I read in the docs and the old source
code I found for my old service. I'm just building a dummy skeleton right now,
which I will clone for the real service.
When I just start up the Tomcat instance with the WAR (I haven't even directly
made a REST service call yet), I see the following in the console:
-------------------
Aug 02, 2016 9:06:24 AM org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
processRequest
WARNING: No root resource matching request path /webproj// has been found,
Relative Path: /. Please enable FINE/TRACE log level for more details.
Aug 02, 2016 9:06:24 AM org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper
toResponse
WARNING: javax.ws.rs.NotFoundException: HTTP 404 Not Found
at
org.apache.cxf.jaxrs.utils.SpecExceptions.toNotFoundException(SpecExceptions.java:89)
---------------------
I have a project named "webproj", and that's also the "id" of my "jaxrs:server"
in my Spring context. The "address" is just "/srv". The @Path in the single
controller is just "/webproj", and the one controller method has a @Path of
"service/{id}/{name}", and the params are mapped to formal params in the
method. Obviously, some of the path components here are stupid, but I'm just
trying to get it running.
The relevant part of my web.xml would be the following:
-------------------
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.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.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
--------------------
Here's the relevant part of my skeletal application context:
---------------------
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxrs:server id="webproj" address="/srv">
<jaxrs:serviceBeans>
<ref bean="webproj"/>
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</jaxrs:extensionMappings>
</jaxrs:server>
<bean id="webproj"
class="com.att.webproj.services.WebProjController"></bean>
--------------------
(I briefly noticed a bug in how Eclipse created the Spring context, as it
defined the "http://cxf.apache.org/jaxrs" namespace to be mapped to the schema
named "http://cxf.apache.org/schemas/jaxrs-common.xsd". When I removed
"-common", it fixed that particular problem.)
I imagine there are some principles that I've forgotten. Please lead me back
to the path.