This is really confusing for most of us as the book does not cover it in good detail.
Does this mean we would only have one JNDI for this EJB?
Yes. Even if your bean has both local and remote interfaces, there will be only one JNDI name.
Whether the local or remote interfaces will be used, will depend if you narrow or downcast?
Not exactly. To get the local interface of an EJB, you need to have the ejb-local-ref element defined in the deployment descriptor. This element will map the JNDI name you use to lookup to the actual bean name.
For instance,
If Bean B needs Bean A's local interface, Bean B should define ejb-local-ref in its deployment descriptor.
To get the remote interface of an ejb, you need to have ejb-ref element defined in your deployment descriptor.
Example:
To lookup remote interface, use jndi.lookup("java:comp/env/BeanARemoteRef") and then
narrow the stub to get the remote home object.
To lookup local interface, use jndi.lookup("java:comp/env/BeanALocalRef") and then
type cast the object returned to get the local home object.