title: Elasticsearch RestHighLevelClient missing transitive dependencies
body: <p>I'm trying to use the RestHighLevelClient via this dependency</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.elasticsearch.client&lt;/groupId&gt;
          &lt;artifactId&gt;elasticsearch-rest-high-level-client&lt;/artifactId&gt;
          &lt;version&gt;6.0.1&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>But I keep getting ClassNotFoundExceptions in the <code>RestHighLevelClient</code> class. </p>
  
  <p>When I try to wire up this bean (<code>AwsAmsElasticsearchClientConfig.java</code> : </p>
  
  <pre><code>@Bean(name = "elasticsearchRestClient")
  public RestHighLevelClient getElasticsearchRestClient() {
      RestClientBuilder restClientBuilder = RestClient.builder(
              new HttpHost(HOST, PORT, SCHEME));
  
      restClientBuilder.setHttpClientConfigCallback(
              new RestClientBuilder.HttpClientConfigCallback() {
                  @Override
                  public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                      httpClientBuilder.addInterceptorLast(buildAwsSigningRequestInterceptor());
                      // add SSL config if needed
                      //  httpClientBuilder.setSSLContext(null);
                      return httpClientBuilder;
                  }
              }
      );
  
      return new RestHighLevelClient(restClientBuilder);
  }
  </code></pre>
  
  <p>I receive these errors: </p>
  
  <pre><code>19:51:11.026 ERROR [           main]                SpringApplication - Application startup failed
  java.lang.ClassNotFoundException: org.elasticsearch.common.CheckedConsumer
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [1 skipped]
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig.getElasticsearchRestClient(AwsAmsElasticsearchClientConfig.java:63) [2 skipped]
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07.CGLIB$getElasticsearchRestClient$0(&lt;generated&gt;)
  Wrapped by: java.lang.NoClassDefFoundError: org/elasticsearch/common/CheckedConsumer
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig.getElasticsearchRestClient(AwsAmsElasticsearchClientConfig.java:63) [2 skipped]
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07.CGLIB$getElasticsearchRestClient$0(&lt;generated&gt;)
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07$$FastClassBySpringCGLIB$$fba1a4f2.invoke(&lt;generated&gt;)
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07.getElasticsearchRestClient(&lt;generated&gt;) [2 skipped]
      at java.lang.reflect.Method.invoke(Method.java:498) [3 skipped]
  Wrapped by: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/elasticsearch/common/CheckedConsumer
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig.getElasticsearchRestClient(AwsAmsElasticsearchClientConfig.java:63) [2 skipped]
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07.CGLIB$getElasticsearchRestClient$0(&lt;generated&gt;)
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07$$FastClassBySpringCGLIB$$fba1a4f2.invoke(&lt;generated&gt;)
      at com.glassdoor.applicantManagement.aws.AwsAmsElasticsearchClientConfig$$EnhancerBySpringCGLIB$$c8f9ed07.getElasticsearchRestClient(&lt;generated&gt;) [2 skipped]
      at java.lang.reflect.Method.invoke(Method.java:498) [3 skipped]
  Wrapped by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.RestHighLevelClient]: Factory method 'getElasticsearchRestClient' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/elasticsearch/common/CheckedConsumer
      at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:192) [148 skipped]
      at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:174)
      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
  </code></pre>
  
  <p>It looks like tons of the transitive dependencies are missing 
  <a href="https://i.stack.imgur.com/6M4q5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6M4q5.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>Turns out there were two things going on here. </p>
  
  <ol>
  <li><p>As @miroh pointed out below I need to explicitly define the <code>org.elasticsearch:elasticserach:6.0.1</code> dependency so I don't get the wrong version pulled in. Not sure why this is necessary but it seems to indeed be necessary ... (also referenced here : <a href="https://github.com/elastic/elasticsearch/issues/26959" rel="nofollow noreferrer">https://github.com/elastic/elasticsearch/issues/26959</a>)</p></li>
  <li><p>My project is a multi module Spring project with many other dependencies. Apparently, some of the Spring/Springboot dependencies were dependent on <code>spring-data-elasticsearch</code> which has a dependency on <code>org.elasticsearch:elasticsearch:2.4.6</code>. I resolved these conflicting versions of elasticsearch by adding the elasticsearch:6.0.1 version to the dependency management section of my parent <code>pom.xml</code>. This tells maven to use version 6.0.1 when dependency conflicts are present. </p></li>
  </ol>