# NoSuchMethodError for client.updateByQuery(...)

**URL:** https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647
**Category:** Elasticsearch
**Created:** [April 12, 2019, 2:26pm UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647 "2019-04-12T14:26:36Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 12, 2019, 2:26pm UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/1 "2019-04-12T14:26:36Z")

</div>

**Elasticsearch version** (`6.7.1`):

**JVM version** (`1.8.0_121`):

**OS version** (`windows-7`):

**Description of the problem including expected versus actual behavior** :  
While issuing a request to update by query using `RestHighLevelClient.updateByQuery(UpdateByQueryRequest, RequestOptions)`, I get the following error:

```auto
java.lang.NoSuchMethodError: org.elasticsearch.index.reindex.BulkByScrollResponse.fromXContent(Lorg/elasticsearch/common/xcontent/XContentParser;)Lorg/elasticsearch/index/reindex/BulkByScrollResponse;
	at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
	at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:965)
	at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:990)
	at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1385)
	at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1726)
	at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:442)
	at org.elasticsearch.client.RestHighLevelClient.updateByQuery(RestHighLevelClient.java:556)

```

After searching around I found out that I might be using an older version of elastic-search. To confirm the above used versions, I placed the following dependencies as first entries in my `pom.xml` :

```auto
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>6.7.1</version>
        </dependency>
        <dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>elasticsearch-rest-high-level-client</artifactId>
		<version>6.7.1</version><!--$NO-MVN-MAN-VER$ -->
	</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: [April 12, 2019, 2:33pm UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/2 "2019-04-12T14:33:09Z")

</div>

What is the output of:

```
mvn dependency:tree
```

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 12, 2019, 3:11pm UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/3 "2019-04-12T15:11:48Z")

</div>

```
[INFO] +- org.elasticsearch:elasticsearch:jar:6.7.1:compile
[INFO] | +- org.elasticsearch:elasticsearch-core:jar:6.7.1:compile
[INFO] | +- org.elasticsearch:elasticsearch-secure-sm:jar:6.7.1:compile
[INFO] | +- org.apache.lucene:lucene-core:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-analyzers-common:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-backward-codecs:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-grouping:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-highlighter:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-join:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-memory:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-misc:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-queries:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-queryparser:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-sandbox:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-spatial:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-spatial-extras:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-spatial3d:jar:7.7.0:compile
[INFO] | +- org.apache.lucene:lucene-suggest:jar:7.7.0:compile
[INFO] | +- org.elasticsearch:elasticsearch-cli:jar:6.7.1:compile
[INFO] | | \- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] | +- com.carrotsearch:hppc:jar:0.7.1:compile
[INFO] | +- joda-time:joda-time:jar:2.10.1:compile
[INFO] | +- com.tdunning:t-digest:jar:3.2:compile
[INFO] | +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.11.1:compile
[INFO] | \- org.elasticsearch:jna:jar:4.5.1:compile
[INFO] +- org.elasticsearch:elasticsearch-x-content:jar:6.7.1:compile
[INFO] | +- org.yaml:snakeyaml:jar:1.23:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.7:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.9.7:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.7:compile
[INFO] | \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.9.7:compile
[INFO] +- org.elasticsearch.client:elasticsearch-rest-client-sniffer:jar:6.7.1:compile
[INFO] | +- org.elasticsearch.client:elasticsearch-rest-client:jar:6.4.3:compile
[INFO] | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.4:compile
[INFO] | | \- org.apache.httpcomponents:httpcore-nio:jar:4.4.10:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.6:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.10:compile
[INFO] | +- commons-codec:commons-codec:jar:1.11:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.elasticsearch.client:elasticsearch-rest-high-level-client:jar:6.7.1:runtime
[INFO] | +- org.elasticsearch.plugin:parent-join-client:jar:6.7.1:runtime
[INFO] | +- org.elasticsearch.plugin:aggs-matrix-stats-client:jar:6.7.1:runtime
[INFO] | +- org.elasticsearch.plugin:rank-eval-client:jar:6.7.1:runtime
[INFO] | \- org.elasticsearch.plugin:lang-mustache-client:jar:6.7.1:runtime
[INFO] | \- com.github.spullara.mustache.java:compiler:jar:0.9.3:runtime
...
```

---

<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: [April 12, 2019, 4:51pm UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/4 "2019-04-12T16:51:11Z")

</div>

I don't see the full output but anyway there are some things you should probably fix like:

```
org.elasticsearch.client:elasticsearch-rest-client:jar:6.4.3:compile
```

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 13, 2019, 2:26am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/5 "2019-04-13T02:26:41Z")

</div>

Hi @dadoonet  
That's a good advice.  
`rest-client:jar:6.4.3` comes from `rest-client-sniffer:jar:6.7.1`. Should I explicitly set the rest-client version to 6.7.1?

Also, the program compiles correctly. How should I ensure that the dependencies used at compile time are picked up at runtime as well?

---

<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: [April 13, 2019, 4:18am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/6 "2019-04-13T04:18:35Z")

</div>

I don't see the full pom but I suspect you are using spring boot. Are you?

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 13, 2019, 7:48am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/7 "2019-04-13T07:48:30Z")

</div>

Yes. Some of the dependencies were coming from `boot-starter-web`.  
I have cut short the pom to show elastic-search 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: [April 13, 2019, 8:31am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/8 "2019-04-13T08:31:07Z")

</div>

See [org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J](https://discuss.elastic.co/t/org-springframework-web-util-nestedservletexception-handler-dispatch-failed-nested-exception-is-java-lang-nosuchmethoderror-org-elasticsearch-action-index-indexrequest-ifseqno-j/176627/2?u=dadoonet)

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

Basically add this to your project to workaround the problem

> <https://github.com/dadoonet/legacy-search/commit/ecf586f9f1b887354e975d3ecba36f1c7d010ba8>

Another way is documented at: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions)

You can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.0.0<elasticsearch.version>
</properties>

```

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 29, 2019, 5:23am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/9 "2019-04-29T05:23:11Z")

</div>

Hey!  
I am not able to upgrade the ES version even after following the mentioned solutions.

I have the following maven project hierarchy:

```
root(contains spring-boot-dependencies 2.1.1.RELEASE)
   +-services
      +-datamanagement()
      +-sample-project(depends on datamanagement)

```

My datamanagement pom.xml content:

```
<properties>
		<java.version>1.8</java.version>
		<elasticsearch.version>6.7.1</elasticsearch.version>
	</properties>

	<dependencies>
	
		<dependency>
			<groupId>org.elasticsearch</groupId>
			<artifactId>elasticsearch</artifactId>
			<version>${elasticsearch.version}</version>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch</groupId>
			<artifactId>elasticsearch-x-content</artifactId>
			<version>${elasticsearch.version}</version>
		</dependency>
		<dependency>
			<groupId>org.elasticsearch.client</groupId>
			<artifactId>elasticsearch-rest-client-sniffer</artifactId>
			<version>${elasticsearch.version}</version>
		</dependency>
		<dependency>
			<groupId>org.elasticsearch.client</groupId>
			<artifactId>elasticsearch-rest-client</artifactId>
			<version>${elasticsearch.version}</version>
		</dependency>
		<dependency>
			<groupId>org.elasticsearch.client</groupId>
			<artifactId>elasticsearch-rest-high-level-client</artifactId>
			<version>${elasticsearch.version}</version>
		</dependency>
		<dependency>
			<groupId>org.elasticsearch.plugin</groupId>
			<artifactId>elasticsearch-scripting-painless-spi</artifactId>
			<version>6.7.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

```

Running **mvn dependency:tree** on **datamanagement** shows that it uses ES version 6.7.1.compile

Running **mvn dependency:tree** on **sample-project** shows that it uses ES version 6.4.3.compile (expected 6.7.1.compile)

---

<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: [April 29, 2019, 7:32am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/10 "2019-04-29T07:32:58Z")

</div>

When you depend on a project you don't set the maven properties.  
You need to add elasticsearch.version in both projects or use a parent pom project.

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 29, 2019, 9:29am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/11 "2019-04-29T09:29:14Z")

</div>

Yes. I am using parent pom which contains `spring-boot-dependencies 2.1.1.RELEASE` inside dependencyManagement.  
Added `elasticsearch.version` as 6.7.1, in both root project as well as child project.  
Still, it uses version 6.4.3.

---

<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: [April 29, 2019, 9:46am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/12 "2019-04-29T09:46:35Z")

</div>

I think you are doing something wrong.  
Share your project on Github if you want us to give a look.

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 29, 2019, 9:47am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/13 "2019-04-29T09:47:17Z")

</div>

Github is not permitted. I can share individual poms.  
Will that do?

---

<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: [April 29, 2019, 9:57am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/14 "2019-04-29T09:57:57Z")

</div>

Sure

---

<div class="post-metadata">

### Author: ![BlueSpirit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluespirit/32/44056_2.png) [@BlueSpirit](https://discuss.elastic.co/u/BlueSpirit)
#### Post date: [April 29, 2019, 11:33am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/15 "2019-04-29T11:33:17Z")

</div>

Added the files as new question [here](https://discuss.elastic.co/t/upgrading-elastic-search-in-spring-boot/178918)

---

<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: [May 27, 2019, 11:33am UTC](https://discuss.elastic.co/t/nosuchmethoderror-for-client-updatebyquery/176647/16 "2019-05-27T11:33:18Z")

</div>

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