This Print JNDI tree - Read Now

This Print JNDI tree - Read Now - is the keyword that you are looking for, and we have it available to you on the blog All About Gadgets, on this occasion we will discuss the article entitled This Print JNDI tree - Read Now, we as admins on this blog has been providing information to you that we collected from various sources so that the information we present a very complete and lots of start about android, latest gadgets of various brands are like samsung, sony, asus, iphone, blackberry, we also provide information about how to fix a mobile phone, flash, rooting. so do not let you stay informed about the latest gadgets in this blog, hopefully our writing easy to understand, ok let please continue reading:

he information you are looking for : This Print JNDI tree - Read Now
Full article : This Print JNDI tree - Read Now
Article java, Article sample code, Article tips and tricks,

You can also see our article on:

This Print JNDI tree - Read Now

At one point or another most of us would have wanted to see what was in the JNDI tree of the Application Server. This may have been because of a javax.naming.NameNotFoundException thrown by the application under development.

After scouring the internet and not finding a way to do this seemingly simple task, I put this together in about an hours time.

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;

public class JNDITree {
private Context context = null;

public static void main(String[] args) throws Exception {
new JNDITree().printJNDITree("");

public JNDITree() throws NamingException {

/* Please modify this method or comment and use
public void setEnv() throws NamingException {
Hashtable env = new Hashtable();
//  env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
//  env.put(Context.PROVIDER_URL, "ormi://172.16.x.x:12404");
//  env.put(Context.SECURITY_PRINCIPAL, "admin");
//  env.put(Context.SECURITY_CREDENTIALS, "welcome");
//  env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
//  env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
//  env.put(Context.PROVIDER_URL, "jnp://172.16.x.x:1099");
//  env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
//  env.put(Context.PROVIDER_URL, "t3://172.16.x.x:7001");

context = new InitialContext(env);

public void printJNDITree(String ct)   {
try {
 printNE(context.list(ct), ct);
} catch (NamingException e) {
 //ignore leaf node exception

private void printNE(NamingEnumeration ne, String parentctx) throws NamingException {
while (ne.hasMoreElements()) {
 NameClassPair next = (NameClassPair) ne.nextElement();
 printJNDITree((parentctx.length() == 0) ? next.getName() : parentctx + "/" + next.getName());

private void printEntry(NameClassPair next) {
System.out.println(printIndent() + "-->" + next);

private int indentLevel = 0;

private void increaseIndent() {
indentLevel += 4;

private void decreaseIndent() {
indentLevel -= 4;

private String printIndent() {
StringBuffer buf = new StringBuffer(indentLevel);
for (int i = 0; i < indentLevel; i++) {
 buf.append(" ");
 return buf.toString();

This seemed to have worked very well for me and I thought I'd share it incase any of you have the same need.
In case anyone has a better way of doing this, kindly comment.

P.S. Dont forget to edit the setEnv() method to set the InitialContext. Default values have been given for a few App Servers.
Alternatively, comment the method out and use with values corresponding to your application server.

Articles This Print JNDI tree - Read Now we have presented

A few information are discussed This Print JNDI tree - Read Now, hopefully we can give benefit to you in finding information on The latest technological gadgets.

You've finished reading an article This Print JNDI tree - Read Now and url link of this article is can you use a bookmark. Hopefully this article could be useful and do not forget to look for more information in the blog All About Gadgets, thanks.

Tag : , , ,

0 Response to "This Print JNDI tree - Read Now"

Post a Comment