Hi David
On 02/08/16 17:21, KARR, DAVID wrote:
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.
Welcome back :-)
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 can only guess that if you start a test war inside Eclipse the client
code does some initial call directly against the war context root (some
index.html check, etc) which may explain why you are seeing the above
trace without even doing a direct call.
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.
I think you should have requests like
localhost:8080/webproj/srv/webproj/service/1/a matched.
Note you have a duplicate 'webproj' - the 1st one is a war context, the
2nd one is from a root @Path, may be you can have a root Path set to "/"
or "", so you will get
localhost:8080/webproj/srv/service/1/a
setting a jaxrs:server/@address to "/"
will let you have
localhost:8080/webproj/service/1/a
HTH, Sergey
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/