code: public static <T> T lookup(String name) {
          InitialContext initialContext = initialContext();
          try {
              @SuppressWarnings("unchecked")
              T object = (T) initialContext.lookup(name);
              if (object == null) {
                  throw new NameNotFoundException(name + " was found but is null");
              }
              return object;
          } catch (NameNotFoundException e) {
              throw new IllegalArgumentException(name + " was not found in JNDI", e);
          } catch (NamingException e) {
              throw new IllegalArgumentException("JNDI lookup failed", e);
          } finally {
              closeContext(initialContext);
          }
      }
docs: Lookup object in JNDI
  
  @param name object name
  @param <T>  object class parameter type
  @return object