Naming server

In IBM WAS Network Deployment V5.1, a naming server exists in every server process (appserver, Node Agent, and Deployment Manager). You can bootstrap your client to any of these naming servers. Usually servlets, EJB clients, and J2EE clients start their bootstrap from their local application server and end up on the server where the objects are found.

For Java clients, you can bootstrap to more than one naming server on different Node Agents as shown in Example 10-2.

Example 10-2 Java client bootstrapping

prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); 
prop.put(Context.PROVIDER_URL, "corbaloc::host1:2809,:host2:2809"); 
Context initialContext = new InitialContext(prop);
try { java.lang.Object myHome = initialContext.lookup("cell/clusters/MyCluster/MyEJB"); 
myHome = (myEJBHome) javax.rmi.PortableRemoteObject.narrow(myHome, myEJBHome.class); 
} catch (NamingException e) { }

The client automatically tries the bootstrap servers on host1 and host2 until it gets an InitialContext object. The order in which the bootstrap hosts are tried is not guaranteed.

The Node Agent is not workload managed. If a client gets a cached Intitialcontext object and that Node Agent is unavailable, the InitialContext object will not automatically fail over to another Node Agent, so the lookup with this InitialContext object will fail. In order to avoid this problem, you need to disable the cache in your client by supplying the following property when initializing the naming context:

prop.put(PROPS.JNDI_CACHE_OBJECT, PROPS.JNDI_CACHE_OBJECT_NONE)

Where PROPS.JNDI_CACHE_OBJECT is a Java constant defined in com.ibm.websphere.naming.PROPS.

Or more conveniently by setting the Java command line property as:

java -Dcom.ibm.websphere.naming.jndicacheobject=none MyClient

Using Node Agents as bootstrap servers is not recommended because they are not workload managed. Because appservers in a cluster are workload managed, use application servers as bootstrap servers instead as follows:

prop.put(Context.PROVIDER_URL, "corbaloc::host1:9810,:host1:9811, 
:host2:9810, :host2:9811");

The above discussion is only relevant for naming lookup (read) operations. If your application is binding (writing), a failure will occur if the Node Agent is unavailable, since the Node Agent coordinates the binding process.

  Prev | Home | Next

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.