private static URL findConfigFile(ClassLoader classLoader, String name) {
    // First, look in the classpath
    URL result = classLoader.getResource(name);
    if (result == null) {
      // Nope, so look to see if our conf dir has been explicitly set
      result = seeIfConfAtThisLocation("METASTORE_CONF_DIR", name, false);
    }
    if (result == null) {
      // Nope, so look to see if our home dir has been explicitly set
      result = seeIfConfAtThisLocation("METASTORE_HOME", name, true);
    }
    if (result == null) {
      // Nope, so look to see if Hive's conf dir has been explicitly set
      result = seeIfConfAtThisLocation("HIVE_CONF_DIR", name, false);
    }
    if (result == null) {
      // Nope, so look to see if Hive's home dir has been explicitly set
      result = seeIfConfAtThisLocation("HIVE_HOME", name, true);
    }
    if (result == null) {
      // Nope, so look to see if we can find a conf file by finding our jar, going up one
      // directory, and looking for a conf directory.
      URI jarUri = null;
      try {
        jarUri = MetastoreConf.class.getProtectionDomain().getCodeSource().getLocation().toURI();
      } catch (Throwable e) {
        LOG.warn("Cannot get jar URI", e);
      }
      if (jarUri != null) {
        result = seeIfConfAtThisLocation(new File(jarUri).getParent(), name, true);
      }
    }

    if (result == null) {
      LOG.info("Unable to find config file: " + name);
    } else {
      LOG.info("Found configuration file: " + result);
    }

    return result;
  }
This is useful if you need the variable name for a LOG message or
{@link System#setProperty(String, String)}, beware however that you should only use this
with setProperty if you're going to create a configuration via
{@link MetastoreConf#newMetastoreConf()}.  If you are going to create it with HiveConf,
then use {@link #getHiveName()}.
@return metastore.* configuration key
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java