According to the J2EE spec, when you set an environment entry in J2EE,
it lives under "java:comp/env" - correct?
If I wanted to write a standalone java app and lookup a name that was
set during an EJB deployment, how would I go about doing this?
My first try is giving a null pointer exception:
---- foo.java ----
import java.util.Hashtable;
import javax.naming.*;
public class foo {
public static void main(String[] args)
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:1091");
try {
Context ctx = new InitialContext(env);
String s = (String)ctx.lookup("java:comp/env/grkEnvEntry");
System.out.println("s = " + s);
}
catch (NamingException e) {
e.printStackTrace();
}
}
}
[grk@acoldone2 jndi]$ java -classpath ~/j2sdkee1.2/lib/j2ee.jar:. foo
Exception in thread "main" java.lang.NullPointerException:
at
com.sun.enterprise.naming.java.javaURLContext.getComponentContext(javaURLContext.java:391)
at
com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:52)
at javax.naming.InitialContext.lookup(InitialContext.java:354)
at foo.main(foo.java:15)
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".