This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Diff b/w dependency lookup and dependency injection while acquiring a stateful session bean instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Diff b/w dependency lookup and dependency injection while acquiring a stateful session bean instance" Watch "Diff b/w dependency lookup and dependency injection while acquiring a stateful session bean instance" New topic
Author

Diff b/w dependency lookup and dependency injection while acquiring a stateful session bean instance

Arun Raja S.K
Greenhorn

Joined: May 30, 2011
Posts: 8
Hi,

I have been reading book "Pro JPA 2 Mastering the java persistence API ". The chapter 3 of this book gives an overview of EJB and dependency management.

At page number 61, it has been stated that " Dependency lookup is the preferred method for acquiring a stateful session bean instance for a
stateless client
". The book also states that Dependency Injection is not good solution to access stateful session bean from stateless components.

Please explain me, how dependency injection differs from dependency lookup (normal context lookup) in case of accessing stateful session bean, though both types provide only reference to the concerned bean?
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Generally speaking DI is similar to JNDI lookup - I believe that DI uses JNDI behind the scene. However you can encounter subtle differences between them:
http://leakfromjavaheap.blogspot.com/2013/02/injecting-stateful-session-bean-into.html


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Diff b/w dependency lookup and dependency injection while acquiring a stateful session bean instance
 
Similar Threads
When did the Stateful Sessionbean created?
Stateful Session Bean - Conversational State
Why not use Dependency Injection of Stateful session bean inside a stateless session bean?
Doubt in SessionBean contract(ejb 3.0 core)
Stateful session bean