I have a basic EJB 3.0 (Java EE 5) project in IBM RAD (aka Eclipse 3.4) and WebSphere 7.0
I created an EAR project, an EJB project (for the EJBs), a JPA project (for the domain objects), and a Dynamic Web project (for my JAX-RS web service).
The EJB project contains an EJB like so:
@Stateless
public TestBean implements TestBeanLocal {
/* ... */
@Local
public TestBeanLocal {
/* ... */
The Web project contains a JAX-RS web service like so:
@Path(value="/mywebservice")
public MyWebService implements Application {
@EJB
private TestBeanLocal myBean;
@GET
@Produces({"text/plain"})
public String getList() {
return myBean.getList();
/* ... */
My problem is the “myBean” attribute in MyWebService is never injected. It’s always null.
Any ideas what I missed?
Thanks,
Rob
The Java EE container will only perform @EJB injection on components it manages. For Java EE 5, this would include servlets, Web services and EJBs. In your case the component is managed by Wink, so the question is whether Wink is expected to interpret @EJB (I guess not). With Java EE 6 injection works because JAX-RS is part of that Java EE version and the component is managed by the container, not by a 3rd party framework.