BlueSpirit
(Aditya Gupta)
April 12, 2019, 2:26pm
1
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:
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
:
<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>
BlueSpirit
(Aditya Gupta)
April 12, 2019, 3:11pm
3
[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
...
dadoonet
(David Pilato)
April 12, 2019, 4:51pm
4
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
1 Like
BlueSpirit
(Aditya Gupta)
April 13, 2019, 2:26am
5
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?
dadoonet
(David Pilato)
April 13, 2019, 4:18am
6
I don't see the full pom but I suspect you are using spring boot. Are you?
BlueSpirit
(Aditya Gupta)
April 13, 2019, 7:48am
7
Yes. Some of the dependencies were coming from boot-starter-web
.
I have cut short the pom to show elastic-search dependencies.
dadoonet
(David Pilato)
April 13, 2019, 8:31am
8
See org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J
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
Another way is documented at: 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
:
<properties>
<elasticsearch.version>7.0.0<elasticsearch.version>
</properties>
1 Like
BlueSpirit
(Aditya Gupta)
April 29, 2019, 5:23am
9
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)
dadoonet
(David Pilato)
April 29, 2019, 7:32am
10
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.
BlueSpirit
(Aditya Gupta)
April 29, 2019, 9:29am
11
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.
dadoonet
(David Pilato)
April 29, 2019, 9:46am
12
I think you are doing something wrong.
Share your project on Github if you want us to give a look.
BlueSpirit
(Aditya Gupta)
April 29, 2019, 9:47am
13
Github is not permitted. I can share individual poms.
Will that do?
BlueSpirit
(Aditya Gupta)
April 29, 2019, 11:33am
15
Added the files as new question here
system
(system)
Closed
May 27, 2019, 11:33am
16
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.