/**
   * @param springCfgPath Spring configuration file path.
   * @return Grid configuration.
   * @throws Exception If failed.
   */
  protected static IgniteConfiguration loadConfiguration(String springCfgPath) throws Exception {
    URL url;

    try {
      url = new URL(springCfgPath);
    } catch (MalformedURLException e) {
      url = IgniteUtils.resolveIgniteUrl(springCfgPath);

      if (url == null)
        throw new IgniteCheckedException(
            "Spring XML configuration path is invalid: "
                + springCfgPath
                + ". Note that this path should be either absolute or a relative local file system path, "
                + "relative to META-INF in classpath or valid URL to IGNITE_HOME.",
            e);
    }

    GenericApplicationContext springCtx;

    try {
      springCtx = new GenericApplicationContext();

      new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(url));

      springCtx.refresh();
    } catch (BeansException e) {
      throw new Exception(
          "Failed to instantiate Spring XML application context [springUrl="
              + url
              + ", err="
              + e.getMessage()
              + ']',
          e);
    }

    Map<String, IgniteConfiguration> cfgMap;

    try {
      cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
    } catch (BeansException e) {
      throw new Exception(
          "Failed to instantiate bean [type="
              + IgniteConfiguration.class
              + ", err="
              + e.getMessage()
              + ']',
          e);
    }

    if (cfgMap == null || cfgMap.isEmpty())
      throw new Exception("Failed to find ignite configuration in: " + url);

    return cfgMap.values().iterator().next();
  }