Java - Java Naming and Directory Interface (JNDI)

Java Conceptuel Diagram

About

JNDI is an interface describing naming and directory functionalities.

It provides applications with methods for performing standard directory operations, such as:

  • associating attributes with objects
  • and searching for objects using their attributes.

Jndi Name Data Source Netbeans

The implementations can be plugged into the JNDI interface using the standard service provider interface (SPI) conventions.

JNDI implementation:

  • LDAP (default),
  • NDS,
  • DNS,
  • and NIS.

Lookup

Three JNDI namespaces are used for portable JNDI lookups:

  • java:global,
  • java:module,
  • and java:app.

global

The java:global JNDI namespace is the portable way of finding remote enterprise beans using JNDI lookups.

JNDI global addresses are of the following form:

java:global[/application name]/module name/enterprise bean name[/interface name]

where:

  • the Default [/application name]/module name is the name of the application and of the module minus the file extension.
  • Application names are required only if the application is packaged within an EAR.
  • The interface name is required only if the enterprise bean implements more than one business interface.

module

The java:module namespace is used to look up local enterprise beans within the same module. JNDI addresses using the java:module namespace are of the following form:

java:module/enterprise bean name/[interface name]

where:

  • The interface name is required only if the enterprise bean implements more than one business interface.

app

The java:app namespace is used to look up local enterprise beans packaged within the same application. That is, the enterprise bean is packaged within an EAR file containing multiple Java EE modules.

JNDI addresses using the java:app namespace are of the following form:

java:app[/module name]/enterprise bean name[/interface name]

where:

  • The module name is optional.
  • The interface name is required only if the enterprise bean implements more than one business interface.

Example

For example, if an enterprise bean, MyBean, is packaged within the web application archive myApp.war, the module name is myApp.

The JNDI name using :

  • java:module namespace is java:module/MyBean
  • the java:global namespace is java:global/myApp/MyBean.

Data Source

With JNDI data source, you can take advantage of connection pooling.

Documentation / Reference





Discover More
Eclipse Project Build Path
J2EE - EJB Remote Client with Eclipse OEPE on Weblogic (Outside the container)

How to create an EJB Remote Client with Eclipse OEPE on Weblogic ? To understand how an EJB is called through lookup, you must first read this article: . In this example, I create a simple EJB with a...
Java Conceptuel Diagram
J2EE - Session Bean

A session bean encapsulates business logic that can be invoked programmatically by a client over local, remote, or web service client views. To access an application that is deployed on the server, the...
Card Puncher Data Processing
JPA - Entity Manager

To manage entities in your persistence application, you need to obtain an javax/persistence/EntityManagerentity manager from an javax/persistence/EntityManagerFactoryEntityManagerFactory. An javax/persistence/EntityManagerEntityManager...
Java Conceptuel Diagram
Java - ( JDK | J2EE | J2SE )

SDK in Java core APIs for writing J2EE components, core development tools, and the Java virtual machine JDBC API 2.0 The Java 2 Platform, Standard Edition (J2SE) SDK is required to run...
J2ee Server
Java - Container

A container is a logical part of a J2EE Server which contains java components Before any component can be executed, it must be assembled. The assembly process involves per logical container: the...
LDAP

The Lightweight Directory Access Protocol () is an application protocol for querying and modifying directory services running over TCP/IP. It's a lightweight replacement (complement) for X500 Directory...
Session Bean Mapped Name
Weblogic - How to Connect a Java Client to a Single Server with JNDI

In addition to the standard Java interfaces for JNDI, WebLogic Server provides its own implementation, weblogic.jndi.WLInitialContextFactory, that uses the standard JNDI interfaces. The JNDI Service...



Share this page:
Follow us:
Task Runner