javaspring-bootelasticsearchelasticsearch-high-level-restclientelasticsearch-rest-client

Elasticsearch method not being found in spring boot


I have been stuck with this issue for a while now and any assistance is appreciated. I am running Spring Boot version 2.2.0 with the ElasticSearch high-level REST Client version 6.4.3 and using version 3.2.0 for the Spring-Data-Elasticsearch version. I am getting the error below. I have tried the following attempts to fix but none do.

  1. Change Spring Boot Version multiple times
  2. Change ES version multiple times
  3. I have cleared my .m2 folder and redownloaded the maven dependencies multiple times.

The issue I am getting below is

An attempt was made to call a method that does not exist. The attempt was made from the following location:

org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate.putMapping(ElasticsearchRestTemplate.java:292)

The following method did not exist:

org.elasticsearch.client.IndicesClient.putMapping(Lorg/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest;Lorg/elasticsearch/client/RequestOptions;)Lorg/elasticsearch/action/support/master/AcknowledgedResponse;

The method's class, org.elasticsearch.client.IndicesClient, is available from the following locations:

jar:file:/Users/user/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.4.3/elasticsearch-rest-high-level-client-6.4.3.jar!/org/elasticsearch/client/IndicesClient.class

It was loaded from the following location: file:/Users/user/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/6.4.3/elasticsearch-rest-high-level-client-6.4.3.jar

Action: Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.IndicesClient

My POM is below

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>3.2.0</version>
    </dependency>

Any help is appreciated. I am sure it has to deal with compatibility issues but not sure which. Thanks all!

Update

I was able to get it run sucessfully by changing my elasticsearch version to 6.7.0. But now I am receiving the following error

org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=index_not_found_exception, reason=no such index]

My POM looks like this below now also.

    <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>6.70</version>
        </dependency>

    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>6.70</version>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>6.70</version>
    </dependency>

Solution

  • Previous issue of method that does not exist. was resolved by changing the elasticsearch version to 6.7.0.

    To avoid these incompatibility issues its always recommend to use the same version of elasticsearch server and its client.