Hi Adam,

I think I know what is happening in this case. When the deserialization error occurs, what happens is that a WebAppplicationException is thrown, and as no custom exception mapper is available, the default one is used, which creates a custom Response object by sending the error message to a client, using a text/plain media type. Given that the original Accept most likely does accept say application/json only, it causes the issue given that no provider can be found that can serialize a text/plain message, due to a text/plain format not being accepted...

Please consider adding a custom WebApplicationException mapper if you can't 
have requests have something like

Accept:application/json,*/*.

I've also updated the code a bit to wrap up the original exception when throwing WebApplicationException, so that one can check the original exception in a mapper and perhaps report a JSON-formatted error message, etc...

Cheers, Sergey

Hi Adam

I agree it's misleading - it's an error during the deserialization which causes 
the problem...
So it's another issue which we need to sort out asap before 2.2 release...

Thanks, Sergey


Thanks for your quick reply.  It looks like I found the issue, if the
incoming Json data is missing the root element ( {id:1} rather than {detail:
{id: 1}} etc.) then it throws that error about not finding a message body
writer. If the root element is there then it works fine. It's kind of a strange message for an input error, but thanks for you help. Playing with the request headers is what helped me find the poorly formatted
JSON.

Thanks again,

Adam


Sergey Beryozkin-2 wrote:

Hi

I hope not... We do have few tests which post and expect the response
back, with the same type involved. Can you please provide few more details. What are ContentType and Accept values ? Thanks, Sergey

-----Original Message-----
From: adam.galloway [mailto:[email protected]] Sent: 24 February 2009 
19:04
To: [email protected]
Subject: JAX-RS response for POST and PUT no longer working


I have a JAX-RS service with create and update methods that return data
objects rather than a JAX-RS Response object.

I am using the 2.2-SNAPSHOT and as of recently I get an error from my
POST
and PUT methods

@Path("my-service")
public class MyService {

@WebMethod
@POST
@Path("/detail/")
@Consumes("application/json")
public Detail createDetail(Detail object) {
   //create detail
   return newDetail;
}

@WebMethod
@GET
@Path("/detail/{id}")
public Detail getDetail(@WebParam(name = "id") @PathParam("id") Long id)
{
  //find detail
  return someDetail;
}

}

The getDetail() method returns the object formatted in json or xml with
no
problem

The createDetail() method returns the following error:
.No message body writer found for response class : Detail.

Is it likely that something in the SNAPSHOT was recently broken?
--
View this message in context:
http://www.nabble.com/JAX-RS-response-for-POST-and-PUT-no-longer-working
-tp22188279p22188279.html
Sent from the cxf-user mailing list archive at Nabble.com.




--
View this message in context: 
http://www.nabble.com/JAX-RS-response-for-POST-and-PUT-no-longer-working-tp22188279p22190574.html
Sent from the cxf-user mailing list archive at Nabble.com.


Reply via email to