I have a very simple java program which is a stand alone client to GFV3.
All it does is call the no-arg InitialContext constructor, and then invoke the following method to print.
The Client is using gf-client.jar on its classpath.
Here is the code:
[code]
try {
Context context = new InitialContext ( );
System.out.pritnln ( "(1) Created initial Context");
listContext (context, "");
} catch (NamingException e ) {
e.printStackTrace();
}
[Context ctx = (Context)new InitialContext()
listContext(ctx, "");
/**
* Recursively exhaust the JNDI tree
*/
private static final void listContext(Context ctx, String indent) {
try {
NamingEnumeration list = ctx.listBindings("");
while (list.hasMore()) {
Binding item = (Binding) list.next();
String className = item.getClassName();
String name = item.getName();
logger.log(Level.INFO, indent + className + " " + name);
Object o = item.getObject();
if (o instanceof javax.naming.Context) {
listContext((Context) o, indent + " ");
}
}
} catch (NamingException ex) {
logger.log(Level.WARNING, "JNDI failure: ", ex);
}
[/code]
If I include only gf-client.jar as per (
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB, step 3) I receive the following exception:
[code]
javax.naming.NoInitialContextException: Need to specify class name in environment or system property or applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContex(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.listBindings(InitialContext.java:447)
at (where I call ctx.listBindings("");).
[/code]
I'm uncertain why I can't call list bindings. Has anyone had success with a remote client talking to GFV3 server via jndi? and can they tell me what I am doing incorrect, even to to get JNDI lookups working would be an incredible step forward...
thanks
[Message sent by forum member 'hoffman462' (HoffmanDanielG_at_comcast.net)]
http://forums.java.net/jive/thread.jspa?messageID=379317