cancel
Showing results for 
Search instead for 
Did you mean: 

Tutorial "Using EJBs in Web Dynpro Applications" ClassCastException

Former Member
0 Kudos

Hi,

I went through the tutorial "Using EJBS in WebDynpro Applications" step-by-step.

If I run the application I always get the following error message:

java.lang.ClassCastException:com.sap.engine.interfaces.cross.ObjectReferenceImpl

if I try to make a lookup to the SessionBean.

I use the following code:

-


InitialContext ctx = new InitialContext();

facadeHome = (FacadeHome) ctx.lookup("FacadeBean"); <- the error is related to this line

facade = facadeHome.create();

-


I have nothing more to provide to be more specifiv.

What did I forget to specify or to define?

Thanks for any help.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi holger,

try to do it like this

InitialContext ctx = new InitialContext();

Object obj = ctx.lookup("FacadeBean");//where FacadeBean is your jndi name

facadeHome = (FacadeHome)PortableRemoteObject.narrow (obj,FacadeHome.class);

facade = facadeHome.create();

hope this helps,

regards,

rahul.

Former Member
0 Kudos

Hi,

Are you sure that FacadeBean is the JNDI name of a bean which has FacadeHome.

and is facadehome variable of type FacadeHome.

ClassCast Exception occurs when you try to typecast a class to a different incomaptible class.

Regards

Bharathwaj

Former Member
0 Kudos

Unfortunately, yes.

All the settings are correct.

I try to cast an object of type "com.sap.engine.interfaces.cross.ObjectReferenceImpl" to "FacadeHome". This throws the error, but I do not know, why the lookup is returning this object.

Former Member
0 Kudos