Elasticsearch method not being found in spring boot

Hello All. I am really glad I found this discussion forum.

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.

Description:

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!

Welcome!

When using springboot with elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your pom.xml:

<properties>
  <elasticsearch.version>7.7.0<elasticsearch.version>
</properties>

See documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions

1 Like

I was able to get it work. Thanks for your reply @dadoonet

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.