Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo() #43023

Closed
huangdeyao opened this issue Jun 10, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@huangdeyao
Copy link

commented Jun 10, 2019

Elasticsearch version:
7.1.1

Plugins installed: []

JVM version (java -version):
openjdk version "1.8" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-suse-lp150.7.1-x8664)
OpenJDK 64-Bit Server VM (build 10.0.2+13-suse-lp150.7.1-x8664, mixed mode)

OS version (uname -a if on a Unix-like system):
centos7.0

Description of the problem including expected versus actual behavior:
I tried to create an index using RestHighLevelClient and encountered a bug,

Steps to reproduce:
pom.xml

   <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.1.1</version>
    </dependency>

java

  @Autowired
    RestHighLevelClient restHighLevelClient;

   @Test
    public void contextLoads() throws IOException {
        XContentBuilder builder = XContentFactory.jsonBuilder();
        builder.startObject();
        {
            builder.field("user", "kimchy");
            builder.timeField("postDate", new Date());
            builder.field("message", "trying out Elasticsearch");
        }
        builder.endObject();
        IndexRequest request = new IndexRequest("test_index")
                .id("1")
                .type("hi")
                .source(builder)
                .opType(DocWriteRequest.OpType.CREATE);
        IndexResponse indexResponse = restHighLevelClient.index(request, RequestOptions.DEFAULT);
        logger.info(indexResponse.toString());
    }

Result:

java.lang.NoSuchMethodError: org.elasticsearch.action.index.IndexRequest.ifSeqNo()J

	at org.elasticsearch.client.RequestConverters.index(RequestConverters.java:329)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1429)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1403)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1373)
	at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:821)
	at com.elastic.search.SearchApplicationTests.contextLoads(SearchApplicationTests.java:56)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

Cannot find declaration to go to
img
The same example (with doc as a type) work in 7.1.1.
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-document-index.html

@romseygeek

This comment has been minimized.

Copy link
Contributor

commented Jun 10, 2019

Hi @huangdeyao, it looks as though you're pulling in an old version of the core elasticsearch jar somehow - running mvn dependency:tree should show you what versions are being used when running the code.

@dadoonet

This comment has been minimized.

Copy link
Member

commented Jun 10, 2019

I suspect he is using SpringBoot 😉. In which case I'd look at #41929 (comment). HTH

@romseygeek

This comment has been minimized.

Copy link
Contributor

commented Jun 10, 2019

Thanks @dadoonet - I'll close this one in favour of #41929 if you don't mind @huangdeyao.

@romseygeek romseygeek closed this Jun 10, 2019

@huangdeyao

This comment has been minimized.

Copy link
Author

commented Jun 10, 2019

thinks;
This is the solution. add dependencies on pom.xml

       <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>7.1.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.1.1</version>
        </dependency>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.