users@jersey.java.net

Re: [Jersey] how to catch 405 errors.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 21 Apr 2010 17:43:10 +0200

On Apr 21, 2010, at 5:35 PM, Diego Gil wrote:

> Maybe the only thing we are missing is the registration of our
> ExceptionMapper implementation, but I couldn't find how to do it.
>
> Any hint ?.
>

See here:

https://jersey.dev.java.net/nonav/documentation/latest/user-
guide.html#d4e217

What is your web.xml?

What is the package the ExceptionMapper is in? is it separate from the
package that the resource classes are in?

In you logs you should expect to see something like the following:

INFO: Root resource classes found:
   class org.Foo
Apr 21, 2010 5:27:07 PM com.sun.jersey.api.core.ScanningResourceConfig
logClasses
INFO: Provider classes found:
   class org.ExceptionMapper

Paul.

> Ragards,
> Diego.
>
>
> On Wed, 2010-04-21 at 16:51 +0200, Paul Sandoz wrote:
>> Hi Diego,
>>
>> Some questions:
>>
>> 1) What version of Jersey are you using?
>>
>> 2) Are you deploying as a servlet?
>>
>> When you say custom format do you mean returning some HTML as
>> response
>> entity or some XML or JSON?
>>
>> You can use an exception mapper for WebApplicatio, check the Response
>> from that exception and then create a new response as appropriate or
>> return the existing response.
>>
>> Paul.
>>
>> On Apr 21, 2010, at 4:43 PM, Diego Gil wrote:
>>
>>> Hi,
>>>
>>> We are developing a small web services repository with Jersey and
>>> facing
>>> now a little issue with error messages.
>>>
>>> If the client makes a wrong request, calling a non existing method
>>> due
>>> to a typo, gets a 405 response. That is ok but we would like to
>>> catch
>>> this exception to use a custom format.
>>>
>>> There is any example of that ?.
>>>
>>> We should use ExceptionMapper or there is another hook to catch that
>>> early errors?
>>>
>>> Thanks,
>>> Diego.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>