Dariusz on Software

Methods and Tools

About This Site

Software development stuff

Archive

How To Debug JNDI Lookup Problems
Fri, 30 Apr 2010 14:27:39 +0000

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

Tags: java.

Tags

Created by Chronicle v3.5