# Caused by: java.lang.NoSuchMethodError: 'void co.elastic.clients.transport.rest\_client.RestClientTransport.\<init\>

**URL:** https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573
**Category:** Elasticsearch
**Tags:** docker, language-clients, runtime-fields
**Created:** [July 28, 2023, 4:18pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573 "2023-07-28T16:18:02Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![aph](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@aph](https://discuss.elastic.co/u/aph)
#### Post date: [July 28, 2023, 4:18pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/1 "2023-07-28T16:18:02Z")

</div>

Maven build is failing with no method found error.

```auto
Caused by: java.lang.NoSuchMethodError: 'void co.elastic.clients.transport.rest_client.RestClientTransport.<init>

```

Here is the pom.xml

```auto
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.ap.search</groupId>
    <artifactId>search-by-phone</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>search-by-phone</name>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>7.17.11</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.17.2</version>
        </dependency>
        <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>8.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.json</groupId>
            <artifactId>jakarta.json-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 28, 2023, 4:19pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/2 "2023-07-28T16:19:46Z")

</div>

You are missing 2 clients with 2 different versions.

```auto
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>7.17.11</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.17.2</version>
        </dependency>
        <dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>8.9.0</version>
        </dependency>

```

Please look at what is needed in the [documentation](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/installation.html).

---

<div class="post-metadata">

### Author: ![aph](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@aph](https://discuss.elastic.co/u/aph)
#### Post date: [July 28, 2023, 4:22pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/3 "2023-07-28T16:22:31Z")

</div>

I am now using this, and still same error. Can you please tell me if I need to remove some extra dependency?

```auto
<dependency>
			<groupId>org.elasticsearch.client</groupId>
			<artifactId>elasticsearch-rest-high-level-client</artifactId>
			<version>7.17.11</version>
		</dependency>
		<dependency>
			<groupId>org.elasticsearch</groupId>
			<artifactId>elasticsearch</artifactId>
			<version>7.17.11</version>
		</dependency>
		<dependency>
			<groupId>co.elastic.clients</groupId>
			<artifactId>elasticsearch-java</artifactId>
			<version>8.9.0</version>
		</dependency>

```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 28, 2023, 4:38pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/4 "2023-07-28T16:38:58Z")

</div>

Where did you see in the documentation I linked to that you have to import:

```auto
<dependency>
			<groupId>org.elasticsearch.client</groupId>
			<artifactId>elasticsearch-rest-high-level-client</artifactId>
			<version>7.17.11</version>
		</dependency>
		<dependency>
			<groupId>org.elasticsearch</groupId>
			<artifactId>elasticsearch</artifactId>
			<version>7.17.11</version>
		</dependency>

```

?

In case you did not see it, let me copy/paste this for you:

```auto
<project>
  <dependencies>

    <dependency>
      <groupId>co.elastic.clients</groupId>
      <artifactId>elasticsearch-java</artifactId>
      <version>8.9.0</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.12.3</version>
    </dependency>

  </dependencies>
</project>

```

But note that you might have some troubles with the spring data dependencies if you are using it, in which case you will need to fix the transitive deps.

Finally you did not tel which elasticsearch version you have?

---

<div class="post-metadata">

### Author: ![aph](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@aph](https://discuss.elastic.co/u/aph)
#### Post date: [July 28, 2023, 4:51pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/5 "2023-07-28T16:51:42Z")

</div>

Elastic version is 8.9.0.  
I am not using spring data, so I removed that dependency. Now the dependencies are like below and its still failing with same error:

```auto
<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-webflux</artifactId>
		</dependency>
		<dependency>
			<groupId>co.elastic.clients</groupId>
			<artifactId>elasticsearch-java</artifactId>
			<version>8.9.0</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.12.3</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.projectreactor</groupId>
			<artifactId>reactor-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 28, 2023, 6:04pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/6 "2023-07-28T18:04:38Z")

</div>

I think that the BOM of spring boot declares something.

Run a

```
mvn dependency:tree

```

To find out what's wrong. Pretty sure that the low level client does not have the right version. See [Maven Repository | Elasticsearch Java API Client [8.9] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/java-rest-low-usage-maven.html)

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 28, 2023, 6:36pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/7 "2023-07-28T18:36:00Z")

</div>

Also look at this : [Installation | Elasticsearch Java API Client [8.9] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/installation.html#class-not-found-jsonprovider)

---

<div class="post-metadata">

### Author: ![ewolfman](https://avatars.discourse-cdn.com/v4/letter/e/5f8ce5/32.png) [@ewolfman](https://discuss.elastic.co/u/ewolfman)
#### Post date: [August 2, 2023, 8:40am UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/8 "2023-08-02T08:40:36Z")

</div>

Hi,

I think I am having the same problem.  
The client of 8.8.2 is working fine.  
When I switch to 8.9.0 I have this error:

```auto
java.lang.NoSuchMethodError: 'void co.elastic.clients.transport.rest_client.RestClientTransport.<init>(org.elasticsearch.client.RestClient, co.elastic.clients.json.JsonpMapper, co.elastic.cl
ients.transport.TransportOptions)'
        at org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchClientConfigurations$ElasticsearchTransportConfiguration.restClientTransport(ElasticsearchClientConfigurations.ja
va:90)

```

Looking at the depedency tree:

```auto
[INFO] +- com.<hidden>:compile
[INFO] | +- co.elastic.clients:elasticsearch-java:jar:8.9.0:compile
[INFO] | | +- org.elasticsearch.client:elasticsearch-rest-client:jar:8.9.0:compile
[INFO] | | | +- org.apache.httpcomponents:httpcore:jar:4.4.16:compile
[INFO] | | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.5:compile
[INFO] | | | +- org.apache.httpcomponents:httpcore-nio:jar:4.4.16:compile
[INFO] | | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | \- org.eclipse.parsson:parsson:jar:1.0.0:compile
[INFO] | +- org.apache.maven:maven-artifact:jar:3.8.1:compile
[INFO] | | \- org.codehaus.plexus:plexus-utils:jar:3.2.1:compile
[INFO] | \- org.springframework.boot:spring-boot-actuator:jar:3.0.7:compile

```

Can you please help?

---

<div class="post-metadata">

### Author: ![ewolfman](https://avatars.discourse-cdn.com/v4/letter/e/5f8ce5/32.png) [@ewolfman](https://discuss.elastic.co/u/ewolfman)
#### Post date: [August 2, 2023, 12:04pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/9 "2023-08-02T12:04:08Z")

</div>

UPDATE: After further investigation, I think the problem might be some incompatibility between org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchClientConfigurations and the 8.9.0 RestClientTransport.  
The exception is:

```auto
2023-08-02T11:29:44.733Z <> {index=1286,scope=,engagement=,session=,request=,span=,thread=main} DEBUG: [o.s.b.d.LoggingFailureAnalysisReporter] Application failed to start due to an exceptio
n
java.lang.NoSuchMethodError: 'void co.elastic.clients.transport.rest_client.RestClientTransport.<init>(org.elasticsearch.client.RestClient, co.elastic.clients.json.JsonpMapper, co.elastic.cl
ients.transport.TransportOptions)'
        at org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchClientConfigurations$ElasticsearchTransportConfiguration.restClientTransport(ElasticsearchClientConfigurations.ja
va:90)

```

And digging into the code of ElasticsearchClientConfigurations:

```auto
    @Import({JacksonJsonpMapperConfiguration.class, JsonbJsonpMapperConfiguration.class, SimpleJsonpMapperConfiguration.class})
    @ConditionalOnBean({RestClient.class})
    @ConditionalOnMissingBean({ElasticsearchTransport.class})
    static class ElasticsearchTransportConfiguration {
        ElasticsearchTransportConfiguration() {
        }

        @Bean
        RestClientTransport restClientTransport(RestClient restClient, JsonpMapper jsonMapper, ObjectProvider<TransportOptions> transportOptions) {
            return new RestClientTransport(restClient, jsonMapper, (TransportOptions)transportOptions.getIfAvailable());
        }
    }

```

The 8.8.2 contructor of RestClientTransport is compatible with the spring boot autoconfigurer:

```auto
    public RestClientTransport(RestClient restClient, JsonpMapper mapper, @Nullable TransportOptions options) 

```

Where as in 8.9.0 the contructor of RestClientTransport has a different contructor:

```auto
    public RestClientTransport(RestClient restClient, JsonpMapper jsonpMapper, RestClientOptions options)

```

As a workaround this works:

```auto
@SpringBootApplication(exclude = org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchClientAutoConfiguration.class )

```

But I think that the solution should be by fixing the 8.9.x java client.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 30, 2023, 12:05pm UTC](https://discuss.elastic.co/t/caused-by-java-lang-nosuchmethoderror-void-co-elastic-clients-transport-rest-client-restclienttransport-init/339573/10 "2023-08-30T12:05:06Z")

</div>

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