Skip to content

Commit caba4f6

Browse files
authored
Add docs for Exception caused by rest-client version mismatch (#647)
1 parent b2b0e47 commit caba4f6

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

docs/troubleshooting/index.asciidoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
// * <<debugging>>
55
// * <<deprecation-warnings>>
66

7-
.Exceptions
7+
[discrete]
8+
=== Exceptions
89

910
* <<missing-required-property>>
10-
* <<serialize-without-typed-keys>>
11+
* <<no-such-method-request-options>>
12+
13+
[discrete]
14+
=== Miscellaneous
1115

16+
* <<serialize-without-typed-keys>>
1217

1318
// [[debugging]]
1419
// === Debugging
@@ -17,4 +22,5 @@
1722
// === Elasticsearch deprecation warnings
1823

1924
include::missing-required-property.asciidoc[]
25+
include::no-such-method-request-options.asciidoc[]
2026
include::serialize-without-typed-keys.asciidoc[]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
[[no-such-method-request-options]]
3+
=== `NoSuchMethodError RequestOptions$Builder.removeHeader` when creating a client
4+
5+
In certain contexts you may encounter an error when creating the `ElasticsearchClient` saying that the method `RequestOptions$Builder.removeHeader` does not exist:
6+
7+
["source","java"]
8+
--------------------------------------------------
9+
java.lang.NoSuchMethodError: 'org.elasticsearch.client.RequestOptions$Builder org.elasticsearch.client.RequestOptions$Builder.removeHeader(java.lang.String)'
10+
--------------------------------------------------
11+
12+
This method was introduced in `elasticsearch-rest-client` version 7.16.0. The error happens because your project is using an older version of this dependency.
13+
14+
This happens in particular when the project is using the https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/[Spring Boot Maven Plugin], as this plugin https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-dependencies/build.gradle[defines versions for commonly used libraries], including `elasticsearch-rest-client`. Depending on the version of Spring Boot used in the project, that version may be outdated.
15+
16+
To solve this issue, you have to add the `elasticsearch-rest-client` dependency explicitly in your project, with the same version as `elasticsearch-java` (see also <<installation>>).
17+
18+
Using Gradle:
19+
20+
["source","groovy",subs="attributes+"]
21+
--------------------------------------------------
22+
implementation 'org.elasticsearch.client:elasticsearch-rest-client:{version}'
23+
--------------------------------------------------
24+
25+
26+
Using Maven:
27+
28+
["source","xml",subs="attributes+"]
29+
--------------------------------------------------
30+
<dependency>
31+
<groupId>org.elasticsearch.client</groupId>
32+
<artifactId>elasticsearch-rest-client</artifactId>
33+
<version>{version}</version>
34+
</dependency>
35+
--------------------------------------------------
36+

0 commit comments

Comments
 (0)