File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes About remote client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "About remote client" Watch "About remote client" New topic

About remote client

Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
In Oreilly EJB 3.0 20.4.2 "JAVA EE Application Client Components", there is an example:
public class MyJavaEEClient
private static @EJB ProcessPaymentRemote processPayment;
public static void main(String [] args) {
jndiCntx = new InitialContext( );
Object ref = jndiCntx.lookup("java:comp/env/ejb/TravelAgent");
TravelAgentRemote bean = (TravelAgentRemote)
Customer cust = new Customer( );
TicketDO ticket = bean.bookPassage(...);

The book says
"Notice that the client component did not need to use a network-specific
JNDI InitialContext. In other words, we did not have to specify the service provider in order to connect to the Java EE server. This is the
real power of the Java EE application client component: location transparency . The client component does not need to know the exact
location of the Ship EJB or choose a specific JNDI service provider; the JNDI ENC takes care of locating the enterprise bean."

But exactly how does the JNDI ENC take care of all these?
If the parameters of InitialContext() are not specified, how does the program locate the remote bean ProcessPaymentRemote? The book doesn't mention either.

Does this client has its own ENC?

In short, this is too magic for me...

Houston Rockets go go go!
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 404
Hi <Cant remember your name >

My understanding is (may be wrong), since application is java ee application client, container provides its environmental properties. if you change default jnp port 1099 to something else, still application client can lookup without any property values.

[ November 18, 2008: Message edited by: Chaminda Amarasinghe ]
Tang Yue
Ranch Hand

Joined: Nov 11, 2008
Posts: 40
"Object ref = jndiCntx.lookup("java:comp/env/ejb/TravelAgent");"

This client use a local jndi lookup. But How can the container for this client(on another machine) locates the remote bean?

As far as I know, the client should use a global lookup like " jndiCntx.lookup("TravelAgent/Remote") "

But why the example doesn't use a global lookup?
I agree. Here's the link:
subject: About remote client
It's not a secret anymore!