Dariusz on Software Quality

30/04/2010

How To Debug JNDI Lookup Problems

Filed under: en — Tags: , — dariusz.cieslak @

Sometimes when you get an exception like this:

javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:"

you want to see what entries are visible in JNDI. No problem, place this code somewhere near lookup problem code location:

InitialContext ic = new InitialContext();
NamingEnumeration it = ic.list("java:comp");
System.out.println("JNDI entries:");
while (it.hasMore()) {
    NameClassPair nc = it.next();
    System.out.println("JNDI entry: " + nc.getName());
}

You will see all JNDI names availailable on console then (you can use your logging library instead of course).

1 Comment »

  1. ${WAS_INSTALL_ROOT}/bin/dumpNameSpace.sh should do the trick also

    Comment by Fokko Groenenboom — 11/06/2010 @

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress