aspose file tools*
The moose likes Websphere and the fly likes JNDI - Object lookup on another AppServer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "JNDI - Object lookup on another AppServer" Watch "JNDI - Object lookup on another AppServer" New topic
Author

JNDI - Object lookup on another AppServer

Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
Hi,

Is there any way to look for a Object on another AppServer? For ex: On 1st AppServer, I am binding an object using
javax.naming.Context context = new javax.naming.InitialContext();
context.bind("objectName", object);
Now from another AppServer, is it possible to access this object using JNDI lookup or some other means.
Please note that we are not using any EJB, our environment is: WAS 4.0, DB2 7, AIX.
Thanks in advance.
Sushil Singh
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
In WebSphere there is a single, shared JNDI namespace that crosses all application servers and clones in the domain. That shared JNDI namespace is held in the administrative database. Your question, therefore, in one respect doesn't make sense since you are always connecting to other application servers, or never, as the case may be...
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
Hi Kyle:
Thanks for your reply.
As you said that "In WebSphere there is a single shared JNDI namespace" that means we should be able to lookup objects between different AppServer. I will appreciate if you can provide me more details.
We are having Vertical clones and each clone is doing its own CACHING (Application data retrieved from DB). This information is 100% same. I was wondering that if only one clone will do the caching and other clone will simply copy CACHE information. This way we will save same resources and the StartUp time for our server.
Thanks in advance.
Sushil Singh
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
How are you doing the caching? Is this something that you wrote internally to your application?
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
We are having our own caching mechanism which is internal to our application. Whenever we restart the AppServer or when AppServer recieves some trigger (which indicates that we got new data), we load/reload all the DATA and store into JVM memory. We use Hashmap to do this caching.
Thanks.
Sushil Singh
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
OK, At least I understand that now. Now, how are you loading this cache? From a database?
WebSphere's JNDI implementation allows you to place just about any serializable object that you want in the naming service. Thre is not a unique name service for each clone (or application server), instead it is shared among all of them.
However, here's the problem -- the JNDI server is based on a database also (the admin database). It will probably not be faster to look things up from JNDI than it will be to have each app server load them up directly from your own database and cache them themselves.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
Hi Kyle:
Thanks for your reply.
I did a small test to verify whether its possible to perform lookup between AppServer (same NODE). But I was not sucessful.
Following is the sequence which I am following:
On AppServer 1:
===============
1. Context ctx = new InitialContext();
2. ctx.bind("objName", testObject);
3. Perform lookup to double check:
ctx.lookup("objName") - Sucessful
On AppServer 2: (Same Node)
=============================
1. Context ctx = new InitialContext();
2. Object testObject = (Object) ctx.lookup("objName") - FAILED javax.naming.NameNotFoundException
Then I tried another combination on AppServer 2:
1. Properties p = new Properties()
2. p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
3. p.put(Context.PROVIDER_URL", "iiop://<ip address>:900");
4. Context ctx = new InitialContext(p);
5. ctx.lookup("objName") - FAILED javax.naming.NameNotFoundException
If WebSphere share same namespace then I should be able to perform lookup. Am I missing somethin!
Thanks.
Sushil Singh
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Ok two questions
(1) Are you using AE or AEs? (There's a BIG difference)
(2) Is your test object Serializable?
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
Sam Kumar
Ranch Hand

Joined: Nov 30, 2001
Posts: 38
1) We are using WAS 4.0.1 AE.
2) Yes, my testObject implements Serializable.
Thanks.
Sushil Singh
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Hmmm... Something strange is going on. I might actually have to take this one up with development on Monday. If you implemented Serializable, the test should have worked...
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI - Object lookup on another AppServer