Hi
http://localhost/CRService/CRService/services/r/2
do you have a web app called 'CRService' ?
@Get
is it a typo ? Do you actually @GET in your code ? For some reasons
ReviewsCollection is considered to be a subresource
cheers, Sergey
----- Original Message -----
From: "Nishant Chandra" <[email protected]>
To: <[email protected]>
Sent: Friday, September 18, 2009 10:52 AM
Subject: REST
HI,
I am building a simple REST based application.
Here is the impl class:
@Path("/services/")
@Produces("application/xml")
public class ReviewServiceImpl implements ReviewService {
@Get
@Path("/r/{id}")
public ReviewsCollection getReviews(String id) {
System.out.println("Getreview called with param: " + id);
Review review = new Review(1, "test review");
List<Review> reviewList = new ArrayList<Review>();
reviewList.add(review);
return new ReviewsCollection(reviewList);
}
}
Beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"
default-lazy-init="false">
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxrs:server id="reviewService" address="/CRService">
<jaxrs:serviceBeans>
<ref bean="reviewBean" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="reviewBean" class="com.fr.impl.ReviewServiceImpl" />
</beans>
Hitting: http://localhost/CRService/CRService/services/r/2 returns 404.
Log dump:
ID: 3
Address: /CRService/CRService/services/r/2
Encoding:
Content-Type:
Headers: {connection=[Keep-Alive, TE],
accept-language=[en-US,en;q=0.9], host=[localhost], te=[deflate, gzip,
chunked, identity, trailers], user-agent=[Opera/9.64 (Windows NT 5.1;
U; en) Presto/2.1.1], accept-encoding=[deflate, gzip, x-gzip,
identity, *;q=0], Content-Type=[null], Accept=[text/html,
application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg,
image/gif, image/x-xbitmap, */*;q=0.1], accept-charset=[iso-8859-1,
utf-8, utf-16, *;q=0.1]}
Payload:
--------------------------------------
getreviews called with param:
Sep 18, 2009 3:03:40 PM org.apache.cxf.jaxrs.utils.ResourceUtils
checkMethodDispatcher
WARNING: No resource methods found for resource class
com.fr.impl.type.ReviewsCollection
Sep 18, 2009 3:03:40 PM org.apache.cxf.jaxrs.JAXRSInvoker invoke
SEVERE: No subresource locator found for path /
Sep 18, 2009 3:03:40 PM
org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : no cause is available
Sep 18, 2009 3:03:40 PM
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback
onClose
INFO: Outbound Message
---------------------------
ID: 3
Encoding:
Content-Type: text/xml
Headers: {Date=[Fri, 18 Sep 2009 09:33:40 GMT]}
Payload:
--------------------------------------
The Id value comes out to be null. How do I get rid of the warnings
and make this work?
Nishant