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?
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 jndi.properties 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.
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 jndi.properties 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.