I have a stateless session bean and a servlet. I have declared a private variable like below in servlet:
But above code is doing nothing. Servlet is in a .war module, ejb is in a .jar module and both are in same ear file.
When mySessionBean is accessed in a method nullpointerexception is thrown. Basically mySessionBean is never set. Can anybody help here?
With JBOss 4.2.2 I looked up the EJB programmatically and it worked.
Now I have installed JBoss 5, and I am trying to inject ejb and EntityManager in servlet as below:
But above variables are never set.
Do I have to configure anything in JBoss 5 to enable auto injection? There's not exception either.
I was not using that. But even after its use, this is not working.
Note that this is a project with several EJBs from ejb 2.1. I upgraded one to EJB 3. EJB 2.1's are packaged in ejb2.1.jar and this single EJB 3 with its local interface is packaged in ejb3.jar. ejb2.1 beans are working fine. Even ejb3 bean works fine if I explicitly look it up. Only DI is not working in servlet when I try to inject ejb3.
I have not defined <ejb-ref > tag for EJB 3 session bean in web.xml. Is that necessary? I guess it should not be because explicit lookup finds it and I am able to use it. Any more hints?