Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best practice for connecting to remote JNDI  RSS feed

 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the EJB container and the Web container exist in different VMs, probably on different physical machines, what is the best practices for connecting to JNDI to look up the EJBs' home interfaces?

The possibilities seem to be:

1. Create a hashtable with the EJB container's URL and other info, and then use this hashtable as a parameter to construct the InitialContext object. This way is easiest, but it forces hard coding the EJB server's info into your client apps.

2. Create a jndi.properties in a location accessible to the class loader.

3. Have command line arguments (to the app server startup I assume) that set the Java environment with the EJB server's URL, etc.


Is there a recommended way to do it, or a discussion of pros and cons somewhere? In case this is app server dependent, I'm using WebSphere v. 5.1.x. Thanks!
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked into binding the remote directory service into your local one? That's the wonderful part of JNDI (able to traverse directory services without everything going crazy).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!