Hi all,
I'm having problems with injecting EJBs into Jersey resource classes on
Glassfish v3.1. I've been scouring mailing lists, forums, and google
search results but havent been able to work out a solution... I'm
thinking it's a bug but it just seems too simple to be a bug :)
I have a simple test case that I'm working with now... I bundled
everything as a war. I have two simple classes, TestResource annotated
as a jersey resource with @Path and TestBean annotated as a stateless
session bean with @Stateless. TestResource attempts to use TestBean
via an injected field annotated with @EJB.
I tried annotating the resource with @ManagedBean and @RequestScoped
and I tried putting a beans.xml in the WEB-INF of the war but when
deployed to glassfish the field is always null. What does seem to work
is annotating the resource with @Stateless to turn it into an EJB...
then the field is not-null and TestEJB's methods are invocable from
TestResource.
Is it supposed to be the case that EJBs can be injected into resources
using the @EJB annotation if the resource class is managed or a CDI
named bean? And if so is there any more than a @Managed annotation or
addition of beans.xml is required? The reason I can't set the resource
as a stateless ejb is because of a different jersey problem... jersey
only seems to be able to load ejbs as resources if the ejbs are in the
same module, but I need to be able to have resources in separate
modules and jersey uses java:module portable jndi names to find the
ejbs for injection which fails when the ejbs are in separate modules :(
If JSF/CDI managed beans as resources are supposed to work with ejb
injection they certainly arent working in a very simple test case I
have ready to submit as a bug.
Thanks
- Phillip