users@jersey.java.net

Re: [Jersey] Jersey EJB exception

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Tue, 01 Sep 2009 13:00:05 -0400

Hi Paul,

Glad to hear it's working. Does this mean the Jersey interceptor is
no longer defining @AroundInvoke ?

On Aug 28, 2009, at 10:39 AM, Paul Sandoz wrote:

>
> On Aug 28, 2009, at 4:33 PM, Herak Sen wrote:
>
>> Hi Paul,
>>
>> I just tested and it's working.
>
> Great, thanks for verifying.
>
>
>> I was just wondering how did you fix it?
>>
>
> Jersey registered an ExceptiionMapper for EJBException:
>
> public class EJBExceptionMapper implements
> ExceptionMapper<EJBException> {
>
> private final Providers providers;
>
> public EJBExceptionMapper(@Context Providers providers) {
> this.providers = providers;
> }
>
> public Response toResponse(EJBException exception) {
> final Exception cause = exception.getCausedByException();
> if (cause != null) {
> final ExceptionMapper mapper =
> providers.getExceptionMapper(cause.getClass());
> if (mapper != null) {
> return mapper.toResponse(cause);
> } else if (cause instanceof WebApplicationException) {
> return ((WebApplicationException)cause).getResponse();
> }
> }
>
> return Response.serverError().build();
> }
> }
>
> Kudo goes to Bill Burke happend to propose such a solution on the
> 311 EG mailing list.
>
> Paul.