docs: @FFDCIgnore(Exception.class)
      private Object getObjectInstance(Context c, Hashtable<?, ?> envmt, String className, String bindingName, ResourceInfo resourceRefInfo, IndirectReference ref) throws Exception {
          try {
              // References are supposed to always have a type, but we tolerate
              // references declared in XML that don't have a type, so it's possible
              // that className could be null.  In that case, we skip matching the
              // target type the same as an actual JNDI lookup.
  
              boolean hasJNDIScheme;
              if (bindingName.startsWith("java:")) {
                  Object instance = getJavaObjectInstance(c, envmt, className, bindingName, resourceRefInfo, ref);
                  if (instance != null) {
                      return instance;
                  }
  
                  hasJNDIScheme = true;
              } else {
                  Object resource = createResource(ref.name, className, bindingName, resourceRefInfo);
  
                  // If not found and the customer explicitly provided a binding, then
                  // try again without specifying type. This is for the case where the
                  // actual object produced by the factory is assignable to the reference
                  // type, but not an exact match.
                  if (resource == null && !ref.defaultBinding) {
                      resource = createResource(ref.name, null, bindingName, resourceRefInfo);
                  }
  
                  if (resource != null) {
                      return resource;
                  }
  
                  hasJNDIScheme = JNDIHelper.hasJNDIScheme(bindingName);
                  if (!hasJNDIScheme) {
                      Object service = getJNDIServiceObjectInstance(className, bindingName, envmt);
                      if (service != null) {
                          return service;
                      }
                  }
              }
  
              // If all else fails, try JNDI, which will fail if not enabled.  We only
              // attempt if the binding name has a scheme; we already checked the
              // service registry above, and we want to avoid JNDI if it might use a
              // non-ResourceFactory when a ResourceFactory is available.
              if (hasJNDIScheme) {
                  try {
                      if (c == null) {
                          c = new InitialContext(envmt);
                      }
                      return c.lookup(bindingName);
                  } catch (NoInitialContextException e) {
                      // The object was not found.
                  } catch (NameNotFoundException e) {
                      // The object was not found.
                  }
              }
          } catch (Exception e) {
              String message = Tr.formatMessage(tc, "INDIRECT_LOOKUP_FAILED_CWNEN1006E",
                                                bindingName, className,
                                                e instanceof InjectionException ? e.getLocalizedMessage() : e);
              throw new InjectionException(message, e);
          }
  
          // If this was a default binding and EE 7 default resource support is
          // enabled, then try to create a default resource.
          if (ref.defaultBinding && javaCompDefaultEnabled) {
              Object resource = createDefaultResource(className, resourceRefInfo);
              if (resource != null) {
                  return resource;
              }
          }
  
          // We failed to find an object.
  
          String refName = InjectionScope.denormalize(ref.name);
  
          if (ref.defaultBinding) {
              throw new InjectionException(Tr.formatMessage(tc, "DEFAULT_BINDING_OBJECT_NOT_FOUND_CWNEN1004E",
                                                            bindingName, className, refName));
          }
  
          if (ref.bindingListenerName != null) {
              throw new InjectionException(Tr.formatMessage(tc, "LISTENER_BINDING_OBJECT_NOT_FOUND_CWNEN1005E",
                                                            bindingName, className, refName, ref.bindingListenerName));
          }
  
          throw new InjectionException(Tr.formatMessage(tc, "BINDING_OBJECT_NOT_FOUND_CWNEN1003E",
                                                        bindingName, className, refName));
      }