NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file
March 9th, 2009
Applies to:
Oracle9i Jdeveloper
j2sdk1.4.2_04
Description:
Error while trying to run an EJB session.
Cause:
Incorrect way of accessing an EJB 2.1 EJB Using RMI from a Standalone Java Client.
Try to follow the example (Accessing an EJB 2.1 EJB Using RMI from a Standalone Java Client) as follows which is discussed at http://download-east.oracle.com/docs/cd/B25221_04/web.1013/b14428/usclient.htm#BABDBIAI:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,”oracle.j2ee.rmi.RMIInitialContextFactory”);
env.put(Context.SECURITY_PRINCIPAL, “oc4jadmin”);
env.put(Context.SECURITY_CREDENTIALS, “password”);
env.put(Context.PROVIDER_URL,”opmn:ormi://myServer:oc4j_inst1/ejbsamples”);
Context context = new InitialContext(env);
Object homeObject = context.lookup(“MyCart”);
CartHome home = (CartHome)PortableRemoteObject.narrow(homeObject,CartHome.class);