*UPDATE: *I've discovered that the @EJBs work correctly (are not null) if I
move the @Dependent class into the same jar as the web service. To me this
suggests a classloader issue? An ear's ejb jar can @Inject a class in a
"lib/*.jar", but a class in a "lib/*.jar" can't get an @EJB from a ejb jar
in the ear's root.
It's still unclear to me if this is by design.
On Tue, Apr 8, 2014 at 12:04 PM, Dan Kaplan <dank_at_mirthcorp.com> wrote:
> My original post is here:
> http://stackoverflow.com/questions/22945206/in-cdi-can-a-dependent-class-use-an-ejb
>
> **TL;DR:** Web Service uses an `_at_Inject`ed class, `_at_Inject`ed class uses
> `_at_EJB`s. `_at_EJB`s are null. Why are they null and how do I fix this?
>
> ---
>
> I'm using Glassfish 3 and I have a `_at_Stateless` `_at_WebService` that is
> `_at_Inject`ing a class with a `_at_Dependent` annotation on it. I'd like this
> class to be able to use other stateless ejbs as fields like this:
>
> @EJB(name = "ejb/MySessionBean", beanName = "MySessionBean")
> private MySessionLocal mySessionLocal;
>
> But, when I try to call this web service, these `_at_EJB` fields are null
> (although the `_at_Dependent` class itself seems to be injected into the web
> service correctly). Is it possible to do what I'm trying to do?
>
> I should add that my Web Service and my EJBs are in an EJB jar in an ear's
> root. The `_at_Dependent` class is inside a jar in the ear's lib/ directory.
>
> --
> Thanks,
> Dan
>
--
Thanks,
Dan
--
CONFIDENTIALITY NOTICE: The information contained in this electronic
transmission may be confidential. If you are not an intended recipient, be
aware that any disclosure, copying, distribution or use of the information
contained in this transmission is prohibited and may be unlawful. If you
have received this transmission in error, please notify us by email reply
and then erase it from your computer system.