users@jersey.java.net

Failure to find a valid MessageBodyWriter for the requested mime types creates a response code of 500

From: Alex Treppass <alextreppass_at_googlemail.com>
Date: Fri, 16 Apr 2010 14:02:43 +0100

ContainerResponse.write() uses “application/octet-stream” as a default value
to locate a MessageBodyWriter when it has been unable to locate a valid
MessageBodyWriter (line 250). Instead it should throw a
WebApplicationException for response code 415 (Unsupported Media). Currently
the default value causes a WebApplicationException with response code 500,
which doesn’t tell the client what was wrong with their request.

Note that if you annotate the web application method with
@Consumes(“application/xml”) then a request for any other mime type will
correctly return 415. However if we remove the annotation the request
returns 500. The accepted mime types therefore seem to be tightly coupled
with the interface at compile time. We would ideally like the accepted mime
types to be coupled with the MessageBodyWriters at runtime, allowing the
available data formats (e.g. xml, json, html, atom, rss, etc) to
configurable (e.g. Spring wired).

Regards,