Skip to Content
0
May 30, 2005 at 07:08 AM

Dynamic Calling of EJB

22 Views

Hi,

I want to call an EJB in NetWeaver. I don't know the class of its Home Interface. I only know its JNDI name. So I use the following method.

1. Context context = new InitialContext();

2. Object home = context.lookup( name );

3. EJBHome ejbHome =(EJBHome) PortableRemoteObject.narrow (home, EJBHome.class);

But I got the exception "java.lang.ClassCastException: javax.ejb.EJBHome" when the program runs into 3.

I check the "home" variable, its type is "class com.sap.engine.interfaces.cross.ObjectReferenceImpl".

Could somebody tell me why this doesn't work? Is there any way to call an EJB when we don't know the Home Interface type and only know its JNDI name and the business method?