Skip to Content
0
Former Member
Dec 20, 2007 at 01:06 PM

ClassNotFoundException when using InitialContextFactoryImpl

45 Views

Dear Experts,

I'm trying to access an EJB which has been deployed on SAP J2EE Engine from a J2SE client by following the guide Link: [Accessing Enterprise JavaBeans Using JNDI in SAP NetWeaver Application Server|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/605ff5f2-e589-2910-3ead-e558376e6f3d].

When the program lauch to Context ctx = new InitialContext(props);

A ClassNotFoundException is throw out.

I found the error is caused by the property entry:

props.put(Context.INITIAL_CONTEXT_FACTORY,

"com.sap.engine.services.jndi.InitialContextFactoryImpl");

So which JAR file contains the InitialContextFactoryImpl class? How can I solve this problem?

I copied my code as follow, hope you can help me.

   	Properties props = new Properties();
    	
    	props.put(Context.INITIAL_CONTEXT_FACTORY,
    		"com.sap.engine.services.jndi.InitialContextFactoryImpl");
    	props.put(Context.PROVIDER_URL, "localhost:50004");
    	props.put(Context.SECURITY_PRINCIPAL, "administrator");
    	props.put(Context.SECURITY_CREDENTIALS, "abcd1234");
    	
    	try{
    		Context ctx = new InitialContext(props);
    		Object o = ctx.lookup(
    				"sap.com/CartEAR/REMOTE/CartBean/cart.ejb.CartRemote");
    		cartRemote = (CartRemote) PortableRemoteObject.narrow(o, CartRemote.class);