users@jersey.java.net

Inject EJB into resource class

From: Zach Cox <zcox522_at_gmail.com>
Date: Wed, 26 Aug 2009 14:35:07 -0400

Hi - I'm using GlassFish v3 Prelude with the jersey and glassfish-ejb
components installed. I have a stateless session bean and a root
resource, and am trying to get the bean injected into the resource:

@Stateless
public class PictureEjb {

}

@Path("/pictures")
public class PicturesResource {
    @EJB
    private PictureEjb pictureEjb;
}

However, the pictureEjb instance is always null. I noticed this
thread from Feb 2009 that seems to say that EJB injection into
resources is not supported in JAX-RS 1.0, but is supported in JAX-RS
1.1:

http://n2.nabble.com/Cannot-get-injected-a-reference-of-a-stateless-EJB-td2364551.html

The GlassFish admin console says the installed Jersey component is
version 1.1.1-1.0, which I assume is 1.1+ and should support EJB
injection into resources, but it doesn't seem to be working...

Am I doing something wrong or is EJB injection into resources still
not supported?

Thanks,
Zach