At the end of this chapter you will be able to:

  • Describe naming and directory services
  • Detail the high-level architecture of JNDI
  • Define basic terminology
  • View the JNDI tree in WebLogic Server
  • Use the Administration Console to deploy a startup or shutdown class


What is JNDI?

The Java Naming and Directory Interface (JNDI) is an API that supports accessing naming and directory services in Java programs. The purpose of a naming service is to associate names with objects and provide a way to access objects based on their names. Objects in a naming system can range from files in a file system and names located in Domain Name System (DNS) records, to Enterprise JavaBeans (EJB) components in an application server and user profiles in an LDAP (Lightweight Directory Access Protocol) directory.

As its name implies, JNDI doesn't just deal with naming services. JNDI also encompasses directory services, which are a natural extension of naming services. The primary difference between the two is that a directory service allows the association of attributes with objects, such as an email address attribute for a user object, while a naming service does not. Thus, with a directory service, you can access the attributes of objects and search for objects based on their attributes. You can use JNDI to access directory services like LDAP and Novell Directory Services (NDS) directories.

  • The Java Naming and Directory Interface is an API for accessing different naming and directory services uniformly.

  • This is a major step forward because:

– Different services use vastly different naming schemes

– Java applications will be able to navigate seamlessly across databases, files, directories, objects and networks



  • In WebLogic Server, JNDI serves as a repository and lookup service for J2EE objects including:

  • EJB home stubs
  • JDBC DataSources
  • JMS connection factories, queues and topics
  • RMI stubs


JNDI Structure & Architecture


Naming Service

A naming service provides a method for mapping identifiers to entities or objects:

Naming Service vocabulary:

Binding: Association of an atomic name and an object

Example: is bound to

Namespace: A set of unique names in a naming system






Contexts and Subcontexts

A naming service associates names with objects. An association between a name and an object is called a binding, and a set of such bindings is called a context. A name in a context can be bound to another context that uses the same naming conventions; the bound context is called a subcontext. For example, in a filesystem, a directory (such as /temp) is a context that contains bindings between filenames and objects that the system can use to manipulate the files (often called file handles). If a directory contains a binding for another directory (e.g., /temp/javax), the subdirectory is a subcontext.

  • Subcontexts are referenced through dot delimiters (.)
  • Subcontexts must be created before objects are placed into them

If the following context exists: com.bea.examples

We cannot bind: com.bea.examples.ejb.SomeObject

Without first creating: com.bea.examples.ejb


JNDI for Administrators

  • An administrator needs to understand JNDI because it will be their job to:
  • verify objects are bound in the JNDI tree
  • set security on contexts within the JNDI tree


Viewing the JNDI Tree



Listing JNDI Contents

  • WLST provides a command line utility for viewing JNDI bindings.
  • jndi() changes to the jndi tree and ls() lists the bindings




Startup and Shutdown Classes

You can use startup and shutdown classes to configure a WebLogic Server to perform tasks when you start or gracefully shut down the server. A startup class is a Java program that is automatically loaded and executed when a WebLogic Server is started or restarted.

A shutdown class is a Java program that is automatically loaded and executed when the WebLogic Server is shut down either from the Administration Console or the weblogic.admin shutdown command.

To use startup or shutdown classes, you must configure and assign them to servers or clusters.

You can use a startup class to:

  • initialize objects in memory
  • reconstruct a JNDI tree
  • load critical values from the database
  • recover the system to the state that existed before shutdown

You can use a shutdown class to:

  • Shutdown classes are usually used to free resources obtained by startup classes.


Defining Startup/Shutdown Classes



When Are Startup Classes Loaded?

  • By default, startup classes are loaded after the J2EE deployment units.

  • J2EE deployment units load in this order: JDBC, JMS, Connectors, EJBs, Web Applications.

  • If “Run Before Application Deployments” is checked, then startup class are loaded right before deploying JDBC Data Sources.




In this chapter we discussed:

  • What naming and directory services are
  • The high-level architecture of JNDI
  • Terminology used in naming and directory services
  • How to view the JNDI tree in WebLogic Server
  • How to deploy a startup or shutdown class via Administration Console
  • What startup and shutdown classes are and how they work
  • How to deploy a startup or shutdown class using the Administration Console

Check out our Related Courses

Weblogic Tutorials

Introduction to Clustering Weblogic

Oracle Goldengate Training In Houston

Oracle Weblogic Server Installation