|
Problem(Abstract) |
You can avoid naming-related problems when deploying
enterprise applications containing EJB™ modules on WebSphere® Application
Server V5 releases through proper usage of JNDI naming and initial
context.
This document applies only to applications that perform a direct lookup of
an object in the CosNaming namespace. It does not apply to applications
that use java:comp/env names.
In addition, this document applies only to applications deployed in a
single WebSphere Application Server cell or ND node. Applications
distributed across multiple cells or deployed to multiple ND nodes (for
example, a servlet on server1 that looks up an EJB home on server2) can
exhibit the described symptoms for reasons other than those explained in
this document. |
|
|
|
Cause |
An EJB that worked properly on V5 Base can fail with the
following errors during server startup when it is deployed in a Network
Deployment distributed environment:
javax.naming.NameNotFoundException: <ejb jndi name> [Root
exception is org.omg.CosNaming.NamingContextPackage.NotFound] |
|
|
Resolving the
problem |
There are multiple possible causes for this error, including:
- The application is supplying a provider URL, but is not
specifying a port number.
The port number defaults to 2809. When the application is deployed in a
single Base node environment, the JNDI lookup succeeds because the default
bootstrap port for the Application Server is 2809. However, after the
application is deployed in a distributed ND environment, the JNDI lookup
fails because 2809 is now the default bootstrap port for the node agent.
Supplying a provider URL with an incorrect port number, host name, or IP
address produces similar errors.
- The application supplies a provider URL of
iiop:///.
This URL means localhost:default port and can fail
for the same reason described above. The interesting thing about this URL
is that it was handled differently prior to v5.0 so that applications that
used to work might not work when moved to v5.0. Prior to v5.0, a provider
URL of iiop:/// caused the JNDI code to use the bootstrap host and port
configured for the Object Request Broker (ORB), which might not be the
same thing. The ORB might be configured with a non-default port, because
the name server is running on a non-default port, and the URL still works.
On v5.0, that URL really is interpreted as localhost:default port,
and if that is not the correct bootstrap address, the application fails.
In an distributed Network Deployment environment, the default port is
probably not the correct port.
In summary, if an application component that works on Base Edition throws
a NameNotFoundException in a distributed ND environment, the problem is
likely one of the following:
- An incorrect provider URL as described above.
The JNDI client should generally assume the provider URL is set somewhere
in the environment and that the application should not supply a provider
URL. This is true for both server and client applications.
- More than one server is involved such that JNDI client (Java client,
servlet, or EJB) bootstraps to a server and looks up an object on another
server, but does not qualify the name. This problem is outside the scope
of this document.
Information needed for name resolution is supplied at deployment time, so
again, a provider URL should not be supplied by the application.
Solution:
- Get the default initial context by using empty InitialContext()
constructor or by not setting the provider URL property.
or
- Use Java™ URL lookup names (java:comp/env/<rest of name>) in
accordance with the J2EE programming model. This eliminates the need to
know host names or port assignments, and decouples the application code
from the object binding name in the CosNaming name space. The Java URL
lookup name is defined by the application and any necessary mapping to
application server-specific values is specified in the deployment
information.
|
|
|
|
|
Cross Reference information |
Segment |
Product |
Component |
Platform |
Version |
Edition |
Application Servers |
Runtimes for Java Technology |
Java SDK |
|
|
|
|
|
|