users@jersey.java.net

Re: [Jersey] Re: Produces, type mapping and wierd filter behaviour

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 13 Oct 2010 16:45:29 +0200

On Sep 27, 2010, at 11:43 AM, John Lister wrote:

> On Thu, 23 Sep 2010 at 10:51:31 Paul Sandoz <Paul.Sandoz_at_oracle.com>
> wrote:
>
>> The @Produces annotation is only taken into account when the resource
>> method is invoked and is not processed when a request filter is
>> invoked that throws an exception to terminate the filter chain.
>
> Ok.. seems odd though, If I use the wrong type I get an exception
> that it doesn't match - which is ok.
> However given a list of choices it selects the first accept type
> provided by the client, similarly if a wildcard is in there it
> always returns text/html, both of which seem odd.
>


>> What type of exception are you throwing and are you using an
>> ExceptionMapper?
>
> I'm throwing one of my own exceptions based on RuntimeException
> although I think the same behaviour happens if I throw
> one based on WebApplicationException. I am using an ExceptionMapper
> that correctly picks up the exception and if I throw the
> exception in the resource method I get the correct behaviour.
>

If you could wrap up a little test case it could help me understand
things a little better.


> Given you say that the produces type isn't used in filters, is it
> possible to determine what the method was annotated with in the
> filter and what
> mediatype to use for the response?
>

Yes, if you use a ResourceFilterFactory, you can get access to the
meta-data of a resource method.

Paul.