The most likely cause of this exception is that a resource
reference does not exist for the resource being looked up. To clarify
this, here is some background information.
In all releases of WebSphere Application Server V4.0, two different
types of JNDI lookups are possible.
- The first type of JNDI lookup is a direct, or global, JNDI
lookup. A direct JNDI lookup occurs when your client application looks up
the actual JNDI name of a resource that is bound to the namespace. An
example of this would be:
DataSource ds = (DataSource)ctx.lookup("jdbc/datasourcename");
- The second type of JNDI lookup is an indirect, or local, JNDI
lookup. The indirect JNDI lookup would look like this:
DataSource ds =
(DataSource)ctx.lookup("java:comp/env/jdbc/datasourcename");
The advantage of an indirect JNDI lookup is that it makes your
applications easier to maintain. If the actual JNDI name of a resource
changes, no changes need to be made to your application. This is because
the local JNDI name (the "java:comp/env" name) is mapped to the
global JNDI name through a resource reference. If a resource reference
does not exist, the JNDI lookup will fail with the NamingException
mentioned above. It is also important to note that an indirect JNDI lookup
can only be done from an application within a Java 2 Platform, Enterprise
Edition (J2EE) container (web module, Enterprise JavaBean (EJB) module, or
application client module).
The resource reference can be created by opening your enterprise
application in the Application Assembly Tool (AAT). The following
screenshots show how to create your resource reference:


The JNDI name: field on the Bindings tab must be set to
the actual JNDI name (global JNDI name) that is bound to the namespace.
The Name: field on the General tab can be set to anything.
It is the part of the JNDI name that comes after "java:comp/env"
when an indirect JNDI lookup is done.
|