Skip Headers

Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g Release 3 (10.1.3) B14428-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Setting JNDI Properties in an EJB

If the client is collocated with the target, the client exists within the same application as the target, or the target exists within its parent, then you do not need to initialize JNDI properties. Otherwise, you must initialize JNDI properties in one of the following ways:

This section describes:

- Setting JNDI Properties with the JNDI Properties File

- Setting JNDI Properties with System Properties

- Setting JNDI Properties in the Initial Context

For more information, see:

- "Specifying Credentials in EJB Clients"

- Oracle Containers for J2EE Services Guide

## Setting JNDI Properties with the JNDI Properties File

You can set JNDI properties in a file named `jndi.properties` that conforms to the requirements specified in the `java.util.Properties` method `load`.

If setting the JNDI properties within the `jndi.properties` file, make sure that this file is accessible from the client `CLASSPATH`.

Set JNDI properties as follows:

    <PropertyName>=<PropertyValue>

For example:

    java.naming.factory.initial= oracle.j2ee.server.ApplicationClientInitialContextFactory

For property names, see the field definitions in `javax.naming.Context`.

For an example, see "Specifying Credentials in JNDI Properties".

## Setting JNDI Properties with System Properties

You can set JNDI properties as system properties specified either on the command line as a `-D` argument or as an environment reference (see "Configuring an Environment Reference to an Environment Variable").

## Setting JNDI Properties in the Initial Context

You can set JNDI properties by creating a `HashTable` and populating it with the required properties using `javax.naming.Context` fields as keys and `String` objects as values. When you instantiate the initial context, pass the HashTable into the the initial context constructor.

For an example, see "Specifying Credentials in the Initial Context".