ClassCastException - While type casting Home object after EJB JNDI Lookup

Sun One Application Server throws a ClassCastException when I try to type cast Home object to it's respective interface type.

Here is the code

==============================================

Object obj = PortableRemoteObject.narrow( context.lookup( jndiName ), homeClass);

System.out.println("Remote Object - obj : "+obj);

if (obj !=null){

System.out.println("obj.getClass().getName() : "+obj.getClass().getName());

System.out.println("obj.getClass().getSuperclass() : "+obj.getClass().getSuperclass());

Class[] interfaces = obj.getClass().getInterfaces();

if (interfaces !=null){

for (int count = 0; count < interfaces.length; count++){

System.out.println("interfaces[ " + count +" ].getName() : " + interfaces[ count ].getName());

}

}

}

==============================================

The class name is dislpayed as the Stub class name.

While displaying the interfaces, the Home Interface name is displayed.

But later when I try to type cast it into Home Interface type, it throws a ClassCastException.

Can somebody please check this?

[1646 byte] By [keerthi5678a] at [2007-11-27 1:09:52]
# 1
Please post the stack trace.Also, take a look at our EJB FAQ to make sure you're doing therecommended lookup :https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
ksaksa at 2007-7-11 23:45:10 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...