Forgive me if I'm being dense, but I can't figure out the "correct" way for an EJB client to get an InitialContext for the EJB container's JNDI root.
I'd like to do it in a server-agnostic way, using the COS Naming Service, if possible, but this is proving elusive.
I'm using Sun's reference J2EE SDK, and trying to connect to it from a standalone console app:
Hashtable env = new Hashtable();
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory" );
env.put( "org.omg.CORBA.ORBInitialPort", "1050" );
Context context = new InitialContext( env );
context.lookup( "java:comp/env" );
This fails on the lookup() with a NameNotFoundException. It's binding to the ORB OK, on port 1050, which is the server's ORB port, and it's finding the NamingService, but it can't look up anything inside it.
I'm obviously doing something wrong, but what?
As an aside, is it possible to use the JNDI ENC on the client? This would remove the problem of getting the initial reference to the naming service.