private void unbindFromRelevantContext(String jndiName) throws NamingException {
    String relativeJndiName = jndiName;
    Context ctx = this.javaEEComponent.getContext();

    if (jndiName.trim().startsWith("java:comp/")) {
      relativeJndiName = jndiName.trim().substring("java:comp/".length());
      ctx = this.javaEEComponent.getContext();
    } else if (jndiName.trim().startsWith("java:module/")) {
      relativeJndiName = jndiName.trim().substring("java:module/".length());
      ctx = this.javaEEComponent.getModule().getContext();
    } else if (jndiName.trim().startsWith("java:app/")) {
      relativeJndiName = jndiName.trim().substring("java:app/".length());
      ctx = this.javaEEComponent.getModule().getApplication().getContext();
    } else if (jndiName.trim().startsWith("java:global/")) {
      relativeJndiName = jndiName.trim().substring("java:global/".length());

      if (this.javaGlobalContext == null) {
        logger.debug(
            "java:global context not set on Switchboard: "
                + this.id
                + " will do a manual lookup of java:global context");
        ctx = (Context) new InitialContext().lookup("java:global/");
      } else {
        ctx = this.javaGlobalContext;
      }
    }
    logger.debug("Switchboard " + this.id + " unbinding ENC resource from jndi name: " + jndiName);
    Util.unbind(ctx, relativeJndiName);
  }