How To Debug JNDI Lookup Problems

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 =;
    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).

This entry was posted in en and tagged , . Bookmark the permalink.

One Response to How To Debug JNDI Lookup Problems

  1. Fokko Groenenboom says:

    ${WAS_INSTALL_ROOT}/bin/ should do the trick also

Comments are closed.