11.9.3 EJB clients hosted by non-WebSphere environment
When an EJB application running in WAS V6 is accessed by a non-WebSphere EJB client, the JNDI initial context factory is presumed to be a non-WebSphere implementation. In this case, the default initial context is the cell root. If the JNDI service provider being used supports CORBA object URLs, use the corbaname format shown in Example 11-10 to look up the EJB home.
Example 11-10 corbaname format for EJB home lookup
initialContext.lookup("corbaname:iiop:myHost:2809#cell/clusters/myCluster/myEJB");
According to the URL in Example 11-10, the bootstrap host and server (node agent) port are myHost and 2809. The EJB is installed in a server cluster named myCluster. The EJB is bound in that cluster under the name myEJB.
The server name could also be the name of a non-clustered server. This form of lookup works in the following situations:
With any name server bootstrap host and port configured in the same cell
If the bootstrap host and port belong to a member of the cluster itself
To avoid a single point of failure, the bootstrap server host and port for each cluster member could be listed in the URL.
Example 11-11 corbaname format with multiple addresses for EJB home lookup
initialContext.lookup("corbaname:iiop:host1:9810,host2:9810#cell/clusters/myCluster/myEJB");
The name prefix cell/clusters/<clustername>/ is not necessary if bootstrapping to the cluster itself, but it always works. The prefix is required, however, when looking up EJBs in other clusters. The server binding for the prefix used to access another cluster is implemented in a way that avoids a single point of failure during a lookup.
If the JNDI initial context factory you use does not support CORBA object URLs, the initial context can be obtained from the server, and the lookup can be performed on the initial context.
Example 11-12 corbaname format with multiple addresses for EJB home lookup
Hashtable env = new Hashtable(); env.put(CONTEXT.PROVIDER_URL, "iiop://myHost:2809"); Context ic = new InitialContext(env); Object o = ic.lookup("cell/clusters/myCluster/myEJB");
This form of lookup works from any server in the same cell as the EJB home being looked up. However, this approach does not allow multiple hosts and ports to be specified in the provider URL and does not incorporate the availability advantages of a corbaloc or corbaname URL with multiple hosts and ports belonging to the server cluster members.