dev@jsr311.java.net

Re: JSR311: default EJBExceptionMapper in spec...

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 20 Aug 2009 11:40:31 +0200

HI Bill,

I too have encountered the same issue. Marc and I were discussing it,
and we concluded that WebAppliationException should be allowed to pass
through, but i guess why not any RuntimeException?

I was scratching my head trying to work out a solution dependent on
EJB APIs but it is not possible and the spec states that only Runtime
exceptions in the war/ear annotated with ApplicationException will be
recognized. Thus it will not be portable for a JAX-RS implementation
distributed as part of an app server.

Thus i think what you propose is a good one. Now i can fix a bug :-)

Paul.


On Aug 19, 2009, at 7:33 PM, Bill Burke wrote:

> I'm doing an EJB example in my book and came across the scenario of
> EJBException. Maybe the spec should define a default
> ExceptionMapper for it? Here's a simple one I did:
>
> @Provider
> public class EJBExceptionMapper implements
> ExceptionMapper<EJBException>
> {
> @Context
> private Providers providers;
>
> public Response toResponse(EJBException exception)
> {
> if (exception.getCausedByException() == null)
> {
> return Response.serverError().build();
> }
> Class cause = exception.getCausedByException().getClass();
> ExceptionMapper mapper = providers.getExceptionMapper(cause);
> if (mapper == null)
> {
> return Response.serverError().build();
> }
> else
> {
> return mapper.toResponse(exception.getCausedByException());
> }
> }
> }
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>