Java Jersey未捕获异常

Java Jersey未捕获异常,java,exception,jax-rs,jersey-2.0,Java,Exception,Jax Rs,Jersey 2.0,我的ExceptionMapper的实现如下所示: @Provider public class CaptureUnhandledExceptions implements ExceptionMapper<Throwable> { private static final Logger LOGGER = LogFactory.getLogger(CaptureUnhandledExceptions.class); @Override public Respo

我的
ExceptionMapper
的实现如下所示:

@Provider
public class CaptureUnhandledExceptions implements ExceptionMapper<Throwable>
{
    private static final Logger LOGGER = LogFactory.getLogger(CaptureUnhandledExceptions.class);

    @Override
    public Response toResponse(Throwable exception)
    {
        LOGGER.error("Unhandled exception", exception);
        ErrorMessage em = new ErrorMessage(50099, ExceptionUtils.getRootCause(exception).getMessage(),
                exception.getMessage());
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(em).build();
    }
}
我错过了什么?我必须在
ResourceConfig
中注册我的提供商吗

在应用程序的ResourceConfig中

this.register(com.abccompany.utils.CaptureUnhandledExceptions.class);

修复方法是添加
this.register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJs‌​onProvider.class)
ResourceConfig

中,您是否在日志文件中看到“未处理的异常”?你不需要注册你的自定义异常处理程序类。不……我这样做只是为了确保我没有遗漏任何东西。试着在你的rest方法中故意抛出一个新的异常(“说点什么…”),看看会发生什么。我想我明白了。我必须添加
this.register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class)在我的资源配置中
this.register(com.abccompany.utils.CaptureUnhandledExceptions.class);