But NO. You have to narrow the object as well!

Narrowing forces the object returned from the JNDI lookup to be absolutely, positively, something that implements the home interface. In other words, something you can cast to AdviceHome.

Context ic = new InitialContext();
Object o = ic.lookup("Advisor");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.