hi ctx = new InitialContext(ht); java.lang.Object obj = ctx.lookup("RemoteCabinHome"); CabinHome home = (CabinHome) PortableRemoteObject.narrow(obj, CabinHome.class); Why did we write narrow () method in EJB? Is it necessary to write?what PortableRemoteObject will do here? can't we write directly like this? ctx = new InitialContext(ht); CabinHome home = (CabinHome) ctx.lookup("RemoteCabinHome");
posted 12 years ago
You can do a direct cast, if using EJB 2.0 Local clients. However, communication b/w the Server and client relies on RMI and implement java.rmi.Remote interface. Given the underlying protocol is IIOP, which is generic (and not specifically for Java) and hence the explicit narrowing. Hope this helps.