As part of weblogic admin job, many times developers approach us asking us to show JNDI tree to if there objects are binded to the server. Generally we use "server --> View JNDI Tree" but this pages renders very slowly or it doesn't open as it happened to me today on one particular server. So I had written this basic stand alone client to find out objects.
import javax.naming.*;
import java.util.Hashtable;
public class ListJNDIObjects
{
static Hashtable ht = null;
public ListJNDIObjects()
{
ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://vasserver:9080");
ht.put(Context.SECURITY_PRINCIPAL,"weblogic");
ht.put(Context.SECURITY_CREDENTIALS,"weblogic");
}
public static void main(String args[])
{
try
{
String jndiContext = "";
ListJNDIObjects listJndi = new ListJNDIObjects();
Context context = new InitialContext(ht);
if(args.length != 0)
{
jndiContext = args[0];
}
NamingEnumeration jndiList = context.list(jndiContext);
while(jndiList.hasMore())
{
NameClassPair ncp = (NameClassPair)jndiList.next();
System.out.println(ncp);
}
context.close();
}
catch(NamingException ne)
{
System.out.println("JNDI List failed : " + ne);
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment