users@jersey.java.net

[Jersey] Error when using Jersey 2.0 AsyncResponse/_at_Suspended feature

From: <myxjtu_at_yahoo.com>
Date: Fri, 12 Oct 2012 20:16:53 +0000 (GMT)

I am newbie to jersey (especially to Jersey 2.0). I am very excited to
see the async features in 2.0 and trying to write some sample async web
service.

I read the article on async here:
http://sleeplessinslc.blogspot.com/2012/10/jax-rs-20-jersey-20-preview-
example.html

So I tried to follow the sample. However, I run into errors when I
tried to call the async web service. What I did is: I implemented a
simple web service by following the sample code in the above link:

@GET
@Path("{taskId}")
public void getTaskResult(@Suspended final AsyncResponse ar,
@PathParam("taskId") final Long taskId) {
...
QUEUE_EXECUTOR.submit(new Runnable() {
 
@Override public void run() {
try {
    ...
    ar.resume(resultContainer);
    }
catch (InterruptedException ex) {
    ar.cancel();
  }
}
});
}

Then I call this service using the following code:
 Client client = ClientFactory.newClient();
 Response response =
client.target(UriBuilder.fromUri("http://localhost:9998").path("/taxono
my").build())
               
.request(MediaType.APPLICATION_XML).get(Response.class);

But I got the following error:

WARNING: The following warnings have been detected with resource and/or
provider classes:
WARNING: A HTTP GET method, public void
getXXXX(javax.ws.rs.container.AsyncResponse), MUST return a non-void
type.

Oct 12, 2012 11:51:12 AM com.sun.jersey.spi.container.ContainerRequest
getEntity
SEVERE: A message body reader for Java class
javax.ws.rs.container.AsyncResponse, and Java type interface
javax.ws.rs.container.AsyncResponse, and MIME media type
application/octet-stream was not found.

I googled but still no clue. Do you have any hints? Thanks