cancel
Showing results for 
Search instead for 
Did you mean: 

ClassNotFoundException when using InitialContextFactoryImpl

Former Member
0 Kudos
114

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);

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi YiNing,

I assume you're working with a CE 7.1 version. In this case, please refer to this [article|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/605ff5f2-e589-2910-3ead-e558376e6f3d]. And for the lookup string, even better check the new [EJB Lookup Scheme|http://help.sap.com/saphelp_nwce10/helpdata/en/45/e692b2cfaa5591e10000000a1553f7/frameset.htm].

HTH!

-- Vladimir

Former Member
0 Kudos

Hi Vladimir,

The Article you mentioned is exactly the same one as I refer the in my post, I've also tried the 2nd link you ur reply.

The exception was throw out before the JNDI lookup, so I guess it's not the key.

Thanks anyway.

YiNing

Answers (1)

Answers (1)

Former Member
0 Kudos

Problem solved.

D:\usr\sap\CE1\J00\j2ee\j2eeclient\sap.comtcjeclientlibimpl.jar

should be addes as external library.

Vlado
Advisor
Advisor
0 Kudos

Yes, that's described in that article, in the "Running the Client" section - that's why I linked to it.

My point about the lookup string was that there's a better (recommended) way with the EJB lookup scheme, not that it's causing the issue.

Glad you've solved it

\-- Vladimir