i have a similar problem since I am trying to inject a ConnectionFactory using @Resource annotation, but I am getting null result (no error, just my object is null).
I am trying this in a jsf managed bean. Is this possible or do I have to do it in another way?
You have to add your EJB servers library files and JavaEE API libraries into your projects library directory to run that program outside from the EJB server.
But I suggest to use JNDI lookup for get server side instance if your client program runs outside from the EJB server.
Injection of an enterprise bean in a non-managed POJO is not possible.
If you're trying for something say
private SampleSessionLocal sessionLocal;
in a simple java class, which comes after your servlet takes the input from the client,
then the container would obviously throw a Null Pointer Exception.
As far as I know, an enterprise bean can be injected into the following managed java objects:
1. Another Enterprise Bean ( EJB 2 or EJB 3 compatible).
2. A Servlet
3. JSF class. I am not sure about the JSF thing, but the first two things are for sure.
OCBCD (EJB 3), OCJP (Java SE 6), MCTS (MS SQL Server 2005)
subject: Injection of EJB in POJO class not working..