This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes ejb-reference vs. jndi look up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb-reference vs. jndi look up" Watch "ejb-reference vs. jndi look up" New topic

ejb-reference vs. jndi look up

Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 137
I understand that when look up a EJB A, I can either by its ejb-reference entry in deployment descriptor or its JNDI entry.

It is my understanding that if I look up a bean from a remote client, I must use the JNDI entry; and if I do that from a remote EJB B, I can do either way provided that the deployment descriptor for B defines ejb-reference to A, and use ejb-reference is preferred over a direct JNDI look up.

If I have a delegate class that wraps up the look up logic, and this delegate can be called by either a remote client or another EJB, then, I wil l have to supply two methods, one to look up JNDI for the client to use, and another to look up ejb-reference for other EJBs to use, right? I do not like that, but is there a one-function-fits-all solution?

what is the advantage of using ejb-reference vs. a direct JNDI lookup?

My thought is that, according to EJB spec, the deployer sets JNDI entry, therefore, when we code EJB to call another EJB, we as bean developer do NOT know the JNDI yet. However, the client developer always sees the JNDI, since they get the deployment descriptor after the deployer fills in JNDI. Is my understanding correct? In other words, there really is no difference whether to use ejb-reference or a direct JNDI lookup.

It is sorta covered in the JavaRanch Style Guide.
subject: ejb-reference vs. jndi look up
It's not a secret anymore!