-
Calling EJB 3.0 from Action Class(POJO) (2 messages)
- Posted by: Rajesh Kannan
- Posted on: February 16 2009 04:47 EST
Hi there, I am able call EJB3.0 stateless session bean from servlet client using @EJB annotation(no lookup). But when I try to call the same bean from action class, its throwing NullPointerException. @EJB private EJB3Sample ejb3Sample; When I print ejb3Sample object reference, its showing Null. 1)Can anyone explain the reason why the remote interface (POJI as per EJB3.0 docs) is null in action class whereas its available in servet? 2)can't we use @EJB in action class(POJO)? 3)We can use lookup in action class to get the bean, like...context.lookup("EJB3Sample#com.test.EJB3Sample") though this is working then whats the use of dependency injection? Thanks in advance, RajeshThreaded Messages (2)
- Re: Calling EJB 3.0 from Action Class(POJO) by Sigmund Lundgren on February 18 2009 07:29 EST
- Thanks Sigmund by Rajesh Kannan on February 19 2009 01:01 EST
-
Re: Calling EJB 3.0 from Action Class(POJO)[ Go to top ]
- Posted by: Sigmund Lundgren
- Posted on: February 18 2009 07:29 EST
- in response to Rajesh Kannan
The EJB3 container can only inject into servlets, ejbs, JSF pages(?) but not POJO's. That's the cause of the NPE and why it works in your servlet. /SigmundHi there,
I am able call EJB3.0 stateless session bean from servlet client using @EJB annotation(no lookup). But when I try to call the same bean from action class, its throwing NullPointerException.
@EJB
private EJB3Sample ejb3Sample;
When I print ejb3Sample object reference, its showing
Null.
1)Can anyone explain the reason why the remote interface (POJI as per EJB3.0 docs) is null in action class whereas its available in servet?
2)can't we use @EJB in action class(POJO)?
3)We can use lookup in action class to get the bean, like...context.lookup("EJB3Sample#com.test.EJB3Sample")
though this is working then whats the use of dependency injection?
Thanks in advance,
Rajesh -
Thanks Sigmund[ Go to top ]
- Posted by: Rajesh Kannan
- Posted on: February 19 2009 01:01 EST
- in response to Sigmund Lundgren
Hi Sigmund, Thanks for your clarification. Rajesh