users@jersey.java.net

Re: [Jersey] RE: Jersey EJB exception

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 27 Jul 2009 16:44:45 +0200

Hi Herak,

On Jul 27, 2009, at 4:30 PM, Herak Sen wrote:

> Hello,
>
> The bigger problem that I see here is that to use EJB in a resource
> class(a common use case) one has to make it an EJB too.
> e.g.
> @Stateless
> @Path("/testrs")
> public class TestResource{
> private @ EJB MyEJB myEJB;
> }
> If TestResource is not an EJB then myEJB is not injected and is
> null.

Injection of EE artifacts on non-EJB resource classes will be
supported when we integrate with JSR 299/330 and managed beans, which
are currently slightly moving targets hence why something is not
currently implemented.

In the mean time it is possible to support this by writing your own
Jersey based plugin, see the following to support @Resource which can
easily be modified to support @EJB:

http://glassfish.markmail.org/search/?q=list%3Anet.java.dev.glassfish.users+InjectableProvider+order%3Adate-backward#query
:list%3Anet.java.dev.glassfish.users%20InjectableProvider%20order
%3Adate-backward+page:1+mid:qa52cnhm6ah3avkk+state:results


> On the other if TestResource was not an EJB and myEJB was injected
> correctly then I think throwing WebApplicationException will be
> caught by Jersey
>

I do not understand what you are getting at, can you provide an example?

Paul.

> Herak
>
> From: Herak Sen
> Sent: Thursday, July 23, 2009 11:31 AM
> To: 'users_at_jersey.dev.java.net'
> Subject: Jersey EJB exception
>
> Hi,
>
> when I throw WebApplicationException from resource class, it’s
> always caught as EJBException, thus the client get wrong http error
> code (500).
>
> @Stateless
> @Path("/testrs")
> public class TestResource{
>
> @GET
> public void throwExc(){
>
> throw new WebApplicationException();
>
> }
> }
>
> I guess this should not be the expected behavior.
>
> Thanks
> Herak
>
>
>