users@glassfish.java.net

In CDI, can a _at_Dependent class use an _at_EJB?

From: Dan Kaplan <dank_at_mirthcorp.com>
Date: Tue, 8 Apr 2014 12:04:54 -0700

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
-- 
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.