After storing a reference to an EJB you can easilly retrieve and use it again. Despite the client is able to serialize an EJB handle it doesn't know how to retrieve back that reference. Retrieving a stored Handle object lets you circumvent the JNDI lookup of the EJB instance. To retrieve a stored EJB handle, you have to deserialize it from its stored location.

By retrieving a serialized EJB handle, you can re-create the bean that was originally created and that produced the handle. The sample below shows how to deserialize the EJB:

public class BeanLoader {

  public final void example() {
    try {
      // load a bean instance:
      bean = loadBean();
      // further use bean:
    catch (Exception e) {

  private final SomeBean loadBean() throws Exception {
    // create object input stream:
    ObjectInputStream input = new ObjectInputStream(
      new FileInputStream("Bean.obj"));
    // load serialized reference:
    Handle handle = (Handleinput.readObject();
    // get EJB object:
    return (SomeBeanPortableRemoteObject.narrow(
      handle.getEJBObject(), SomeBean.class);