cancel
Showing results for 
Search instead for 
Did you mean: 

Using Reflection to call EJB

Former Member
0 Kudos

Hai All,

I want to call an ejb from a web dynpro using Reflection technique .

Actually i didnot include any jar in classpath but use only the JNDI name to resolve the jar

the code is :



 Properties pros =new Properties();
 props.put (Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
 props.put(Context.PROVIDER_URL,"sapsrv02:50200");
 InitialContext context = new InitialContext(props);

But it shows Class Cast Exception in code :

EJBHome home = (EJBHome)PortableRemoteObject.narrow(obj,EJBHome.class);

Is it correct to give com.sap.engine.services.jndi.InitialContextFactoryImpl as parameter for Context.INITIAL_CONTEXT_FACTORY or should i give any other class parameter.

Can anyone please help me to resolve this problem.

Thanks in advance.

Regards,

Jude

Edited by: Jude Silvester on Feb 6, 2009 10:58 AM

Edited by: Jude Silvester on Feb 6, 2009 11:01 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You need to add the jars from the following folder to your project class path .../usr/sap/J2E/JC00/j2ee/j2eeclient/

Ex: C:\usr\sap\CE1\ J00\j2ee\j2eeclient

Regards

Ayyapparaj

Former Member
0 Kudos

Hai Ayyapparaj ,

I found the path but can you tell me what are the jars needed to be included in it. Since there are many jars in it.. is it needed to include all or not ?

Please help me to solve this problem. Thank you for your reply.

Regards,

Jude

Former Member
0 Kudos

Hi Jude,

Following is the jar -> sapj2eeclient.jar

Name might be slightly different on your version

in CE its sap.comtcjeclientlibimpl.jar

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyapa,

I tried as you said and still the same error persists .. Is there any other way to call an ejb or

my doubt is on

Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl"

is it the correct class for naming factory or else we should use a class other than this

for eg:

CosNamingFactory...

like that is there any specific jar and Context factory class for Client.

Please help me to solve this problem.

Regards,

Jude

ruben_alvarez
Explorer
0 Kudos

Hi Jude,

Have you found the solution to your problem?

I want to call an EJB but from another EJB.

Thanks in advance.

Regards,