Looks like your custom exception mapper is registered successfully with
Jersey. You can tell that from this line in your server logs:
INFO: Provider classes found:
class
com.foobar.atg.sniffernet.collector.provider.JSONExceptionMapper
Jersey ships an exceptions example that you can look into. It shows all
possible use cases for an exception mapper:
http://download.java.net/maven/2/com/sun/jersey/samples/exceptions/1.7/exceptions-1.7-project.zip
-Arul
On Sat, Jun 18, 2011 at 2:28 PM, <drach_at_itsit.org> wrote:
> I created a small ExceptionMapper that I thought would catch all
> exceptions thrown from my resource class. But it doesn't catch any
> exceptions. That makes me think it's not properly registered. How can
> I tell if it's registered or not? What is the proper way to do it. I
> can't seem to find what I'm looking for in the forums or the samples.
>
> My ExceptionMapper starts off like this:
>
> package com.foobar.atg.sniffernet.collector.provider;
>
> import javax.ws.rs.core.*;
> import javax.ws.rs.ext.*;
>
> @Provider
> public class JSONExceptionMapper implements ExceptionMapper<Exception>
> {
> public Response toResponse(Exception e) {
>
> -------
> My web.xml has this in it:
>
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</s
> ervlet-class>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
> <param-value>com.foobar.atg.sniffernet.collector.resource;
> com.foobar.atg.sniffernet.collector.provider
> </param-value>
>
> ------
> The jetty server log shows this:
>
> INFO: Scanning for root resource and provider classes in the packages:
> com.foobar.atg.sniffernet.collector.resource
> com.foobar.atg.sniffernet.collector.provider
> Jun 18, 2011 12:01:23 PM com.sun.jersey.api.core.ScanningResourceConfig
> logClasses
> INFO: Root resource classes found:
> class com.foobar.atg.sniffernet.collector.resource.DataCollection
> Jun 18, 2011 12:01:23 PM com.sun.jersey.api.core.ScanningResourceConfig
> logClasses
> INFO: Provider classes found:
> class
> com.foobar.atg.sniffernet.collector.provider.JSONExceptionMapper
> class com.foobar.atg.sniffernet.collector.provider.S3ClientResolver
>
--
http://aruld.info
http://twitter.com/aruld