Home

NamingException

NamingException is the base class for exceptions thrown by the Java Naming and Directory Interface (JNDI) when a naming or directory operation fails. It is a checked exception in the javax.naming package and is typically thrown by operations such as Context.lookup, Context.bind, Context.unbind, and Context.list when problems occur with names, contexts, or directory data.

NamingException provides context for debugging and can carry additional information through standard exception chaining. It may

Handling guidance typically involves catching NamingException to address all JNDI errors, or catching particular subclasses to

See also: Java Naming and Directory Interface, javax.naming.

include
an
explanatory
message
and,
in
JNDI,
may
convey
details
about
the
portion
of
the
name
that
was
resolved
and
the
remaining
portion
to
be
resolved.
The
exception
hierarchy
includes
several
concrete
subclasses
that
indicate
specific
failure
modes,
such
as
NameNotFoundException
(the
name
could
not
be
found),
NotContextException
(the
target
is
not
a
context),
InvalidNameException
(the
provided
name
is
invalid),
CannotProceedException
(resolution
cannot
proceed
within
the
current
context),
and
CommunicationException
(a
problem
communicating
with
the
naming
service).
tailor
responses
to
specific
conditions.
As
a
checked
exception,
code
that
performs
naming
operations
must
acknowledge
it
either
with
a
try/catch
block
or
by
declaring
it
in
the
throws
clause.
NamingException
thus
provides
a
uniform
mechanism
for
reporting
problems
in
naming
and
directory
operations
across
different
service
providers
within
JNDI.