public Object getObject() throws NamingException {
    if (reference != null) {
      return reference.getObject();
    }

    SystemInstance systemInstance = SystemInstance.get();

    EjbResolver resolver = systemInstance.getComponent(EjbResolver.class);

    String deploymentId = resolver.resolve(info, moduleUri);

    if (deploymentId == null) {
      String key = "lazyEjbRefNotResolved";
      if (info.getHome() != null) {
        key += ".home";
      }
      String message =
          messages.format(
              key, info.getName(), info.getEjbLink(), info.getHome(), info.getInterface());
      throw new NameNotFoundException(message);
    }

    ContainerSystem containerSystem = systemInstance.getComponent(ContainerSystem.class);

    BeanContext beanContext = containerSystem.getBeanContext(deploymentId);

    if (beanContext == null) {
      String message = messages.format("deploymentNotFound", info.getName(), deploymentId);
      throw new NameNotFoundException(message);
    }

    InterfaceType type = null;
    switch (info.getRefType()) {
      case LOCAL:
        type = InterfaceType.BUSINESS_LOCAL;
        break;
      case REMOTE:
        type = InterfaceType.BUSINESS_REMOTE;
        break;
    }

    String jndiName =
        "openejb/Deployment/" + JndiBuilder.format(deploymentId, info.getInterface(), type);

    if (useCrossClassLoaderRef && isRemote(beanContext)) {
      reference = new CrossClassLoaderJndiReference(jndiName);
    } else {
      reference = new IntraVmJndiReference(jndiName);
    }

    return reference.getObject();
  }
  private void initializeDependencies(BeanContext beanContext) throws OpenEJBException {
    SystemInstance systemInstance = SystemInstance.get();
    ContainerSystem containerSystem = systemInstance.getComponent(ContainerSystem.class);
    for (String dependencyId : beanContext.getDependsOn()) {
      BeanContext dependencyContext = containerSystem.getBeanContext(dependencyId);
      if (dependencyContext == null) {
        throw new OpenEJBException(
            "Deployment does not exist. Deployment(id='" + dependencyContext + "')");
      }

      final Object containerData = dependencyContext.getContainerData();

      // Bean may not be a singleton or may be a singleton
      // managed by a different container implementation
      if (containerData instanceof Data) {
        Data data = (Data) containerData;

        data.initialize();
      }
    }
  }