File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes JNDI on a cluster Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI on a cluster" Watch "JNDI on a cluster" New topic

JNDI on a cluster

Greg Charles

Joined: Oct 01, 2001
Posts: 2968

I'm maintaining some old EJB code. Right now, there is a Session Bean method that stores a piece of information into JNDI. The next time the method runs, it reads the information back. That seems to work fine now, but I suspect that if we ever deploy to a cluster, there will be problems. The second time the method is run could be on a different server with a different JNDI tree. Am I right about that?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Man, did you ever open a can of worms with me.

JNDI is an important topic, and there are many ways to configure JNDI names. The need for using JNDI references in the deployment descriptors embodies the fact that actual JNDI names can change, and programs must be ready for that.

With WebSphere, we have the whole federated namespace, which actually provides about 5 potential means of doing a JNDI indirection, all of which make sense in various situations. It's alot to digest when you're just happy that your JNDI lookup on your local machine worked properly.

Here's an article I wrote on JNDI. It's WebSphere focussed, but the ideas are universal.

Jndi Bindi Bo Bindi Bannana Fana FoFndi Me Mi MoMndi JNDI


-Cameron McKenzie
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

It also depends on the cluster implementation. Since I know JBoss I can let you know how it is implemented. In JBoss, JNDI is replicated, so in the file you can either provide a Multi-cast IP address for the cluster at large, and it can get the information. Or you can provide each and every IP address in the cluster.

Since JNDI is replicated, how it is replicated comes into play on whether it is synchronous replication or asynchronous. with asynchronous, it is possible that the last say 20 seconds of changes hasn't been received on the new node that you are now talking to, but that is a trade off that you need to figure out because how ofter in your cluster does a node go down. Also if you have synchronous, then performance is hit.

Lots about this subject, that research is in order.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425

Since JNDI is replicated, how it is replicated comes into play on whether it is synchronous replication or asynchronous

I believe with JNDI replication you replicate the copy of JNDI tree on the other nodes of the cluster but not the object's binded to the JNDI. I too have question on this.

Assuming I have two servers A, B and user call is routed to Server A which initialize a object (since first time) and binds to JNDI tree. The object bounded by Server A lives in Server A JVM, isn't it?
- What will happen if Server A which created and bounded the Object to JNDI goes down? Sure Server B will have replicated the JNDI copy of Server A but will it be able to resolve the object bounded by Server A?
- Or is the object bounded to server A is replicated on Server B? I guess this will have more memory/performance/version problems
- In weblogic we need to specify the objects (EJB Stub) that are to be replicated in the configuration which make me believe replication is not the default option. I couldn't find a way to create any object, bind to JNDI and get it replicated.
jQuery in Action, 3rd edition
subject: JNDI on a cluster
It's not a secret anymore!