Get the default initial context

 

The following section explains the process of determining the address of the host used to obtain the initial context.

No provider URL is passed to the javax.naming.InitialContext constructor.

Usage scenario

...
import javax.naming.Context;
import javax.naming.InitialContext;
...
Context initialContext = new InitialContext();
...

The default initial context returned depends the runtime environment of the JNDI client. The initial context returned in the various environments are listed below:

Even though no provider URL is explicitly specified in the above example, the InitialContext may find a provider URL defined in other places that it searches for property settings.

Users of properties which affect ORB initialization should read the rest of this section for a deeper understanding of exactly how initial contexts are obtained, which has changed from previous releases.

Determining which server is used to obtain the initial context

WAS name servers are CORBA CosNaming name servers, and WAS provides a CosNaming JNDI plug-in implementation for JNDI clients to perform naming operations on WAS name spaces. The WAS CosNaming plug-in implementation is selected through a JNDI property that is passed to the InitialContext constructor. This property is java.naming.factory.initial, and it specifies the initial context factory implementation to use to obtain an initial context. The factory returns a javax.naming.Context instance, which is part of its implementation.

The WAS initial context factory, com.ibm.websphere.naming.WsnInitialContextFactory, is typically used by WAS applications to perform JNDI operations. The WAS run-time environment is set up to use this WAS initial context factory if one is not specified explicitly by the JNDI client. When the initial context factory is invoked, an initial context is obtained. The following paragraphs explain how the WAS initial context factory obtains the initial context in client and server environments.

 

See Also

Developing applications that use JNDI
Initial context support
Get an initial context by setting the provider URL property