Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI lookup of local and remote home interfaces

 
Naveen Sampra
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB2.0 is supposed to support dual-role beans, where both a local and a remote interface are present in the same bean for maximum flexibility.
But when you do the JNDI lookup to locate the bean, you can create JNDI to locate only one type, i.e home or remote. So, if I have an EJB client that is deployed locally, but wants to use the local interface(on one occasion) AND remote interface(on another occasion) how do you configure the JNDI for the bean to do both.
Can anyone help me with this.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You simply use different JNDI names for the interfaces (i.e. "BeanLocal" and "BeanRemote") and use the appropriate one when looking for the interface you want.
Here's some sample from one deployment descriptor of mine:
<session>
<ejb-name>DepartmentManager</ejb-name>
<jndi-name>DepartmentManager</jndi-name>
<local-jndi-name>DepartmentManagerLocal</local-jndi-name>
</session>
When I want to use the local interface I lookup for the "DepartmentManagerLocal" home interface, and when I want to use the bean remotely I lookup for the "DepartmentManager" home interface.
Hope it's all clear now.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naveen,
What IDE are you using? The JNDI setup for one of the interfaces may be "hidden" somewhere.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic