-
1. Re: How to determine what is in an InitialContext?
bsheward Aug 14, 2006 4:37 PM (in response to bsheward)I've written code which dumps out an InitialContext using the list() method. I used an empty String and "java:" as the inputs which seems to give me decent results. Are there any other names which would make sense?
Also, I found that in some circumstances, as I recurse through the tree of objects within the context, the Enumeration returns by the list() method sometimes returns a String object, rather than a NameClassPair object:private static void dumpContextList( Logger lgr, Level lvl, Context ctx, String name, String prefix) { ... for( Enumeration e = ctx.list( name ); e.hasMoreElements(); ) { Object o = e.nextElement(); if ( o instanceof NameClassPair ) { ... } else { lgr.log( "Found object of Class " + o.getClass().getName() + " = \"" + o.toString() + "\"" ); } } }
Am I missing something here, or is this a bug? -
2. Re: How to determine what is in an InitialContext?
peterj Aug 14, 2006 6:23 PM (in response to bsheward)I don't think I have very seen plain Strings coming back from JNDI, but I have had fun dealing with the Proxy classes, some of which don't appear to have a toString method.
I have noted in my own code that "java:" and "java:comp" tend to return different things. Also try the empty string, that will give you the things in the global namespace. You might also check for subcontexts and dump out the contents of those also.