Even though JBoss comes with JMX console which gives you the graphical view of JNDI tree sometime you might need to print the JNDI tree to look at the absolute path of your boud resources. Here is an example program that can be used to print JBoss JNDI tree.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
package com.ourownjava.corejava.jboss; import java.util.Properties; import javax.naming.*; /** * @author ourownjava.com * @date May 3rd, 2011 * * Example program to print JBoss JNDI tree * */public class JNDIClientExample { public static void main(String args[]) throws Exception { final Properties props = new Properties(); //create the initial context. //change the IP address as per your environment props.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099"); final Context context = new InitialContext(props); final NamingEnumeration<?> enumeration = context.list("/"); while (enumeration.hasMore()) { System.out.println(enumeration.next()); } } } |