The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Remote Invocation of EJB 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 "Remote Invocation of EJB" Watch "Remote Invocation of EJB" New topic

Remote Invocation of EJB

nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
When I first created my ejb application I used the ejb-jar.jar and placed it in the classpath for accessing the bean remotely from my simple java client.
My client code used only this for accessing the bean:

It worked smoothly and I got the required output from the bean.

Since the bean was remotely accessed from the java client, the ejb-jar must have included the stubs for remote invocation. right?

However when I opened the jar file I did not find any other classes apart from my bean classes. How did the java client do the lookup through JNDI? How did it know which server and port to lookup?

There was no ejb-jar.xml in the jar file. Then how did the remote connection happen?

Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Hi nitin.

As far as I understand it, the ejb-jar.xml is used for deploying the ejb-jar into the application server. I fail to see how that is related to the client doing jndi lookups.

On the other hand, it is possible that you have put a in your classpath before running your client. Verify if that is the case, then take a look into that properties' file: you must probably find what you are looking for.

Please, tell me if what I said is right or just nonsense.

SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185

Yea I found it today while reading "EJB 3 in Action". When the server is running in the same JVM as your client you can create a Context without any argument. The JVM is defaulted to find the beans after searching for the app server in its local space. However if the client is running on a different VM then you would have to provide the files specifying the server port and the mappings.

As for the ejb-jar.xml is concerned, yes it is used during deployment. But I used the same jar file for building my client which i also used during deploying the bean.
I agree. Here's the link:
subject: Remote Invocation of EJB
It's not a secret anymore!