【问题标题】:java.lang.IllegalStateException: Received message from unsupported version: [2.0 .0] minimal compatible version is: [5.0.0]java.lang.IllegalStateException:收到来自不受支持版本的消息:[2.0 .0] 最低兼容版本为:[5.0.0]
【发布时间】:2018-01-30 12:23:17
【问题描述】:

我正在尝试做this sample tutorial,以便熟悉elasticsearch。但是运行项目它在intellij中给出了这个错误:

org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected

2017-08-22 13:32:10.489 ERROR 6372 --- [           main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
2017-08-22 13:32:10.669  INFO 6372 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
--ElasticSearch-->
client.type = transport
cluster.name = mkyong-cluster
name = Mahkizmo
network.server = false
node.client = true
transport.ping_schedule = 5s
<--ElasticSearch--
2017-08-22 13:32:10.751  INFO 6372 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-08-22 13:32:10.755 ERROR 6372 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at com.mkyong.Application.main(Application.java:26) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_92]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_92]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_92]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_92]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na]
Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{127.0.0.1}{127.0.0.1:9300}]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:326) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:223) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:295) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) ~[elasticsearch-2.4.4.jar:2.4.4]
    at org.elasticsearch.act

在 elasticsearch.bat 中它给出了这个错误:

java.lang.IllegalStateException: Received message from unsupported version: [2.0
.0] minimal compatible version is: [5.0.0]
        at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport
.java:1379) ~[elasticsearch-5.5.2.jar:5.5.2]
        at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channe
lRead(Netty4MessageChannelHandler.java:74) ~[transport-netty4-5.5.2.jar:5.5.2]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:362) [netty-transport-4.1.11.Final.jar:4.1.11.Fin
al]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:348) [netty-transport-4.1.11.Final.jar:4.1.11.Fin
al]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:340) [netty-transport-4.1.11.Final.jar:4.1.11.Final
]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMes
sageDecoder.java:310) [netty-codec-4.1.11.Final.jar:4.1.11.Final]

我搜索了一下,据说可能是spring boot和elasticsearch版本冲突。但在该教程版本的弹性搜索的 pom 文件中未指定:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>



    <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-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Runtime, for Embedded Elasticsearch,
            comment this if connect to external elastic search server-->
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>org.springframework.data</groupId>-->
            <!--<artifactId>spring-data-commons</artifactId>-->
            <!--<version>1.13.3.RELEASE</version>-->
        <!--</dependency>-->

    </dependencies>

是版本冲突的问题,如何解决?

【问题讨论】:

  • 显然您正在运行 ES 2.x,对吗?
  • @Val 我也这么认为,但你看到这个日志“在 org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport .java:1379) ~[elasticsearch-5.5.2.jar:5.5.2 ]”这里说 5.5.2。消息和日志跟踪不一样
  • 不,我运行的是 ES 5.5.2 @Val
  • 5.5.2 是您正在加载的 JAR,而不是您正在运行的 ES。运行curl -XGET localhost:9200 会得到什么?
  • name "87VwbOg" cluster_name "mkyong-cluster" cluster_uuid "u54dczmGQ0Ge6F5FO5HcDw" 版本号 "5.5.2" build_hash "b2f0c09" build_date "2017-08-14T12:33:14.154Z" build_snapshot false lucene_version " 6.6.0" 标语“你知道,搜索”@Val

标签: java spring maven elasticsearch spring-data-elasticsearch


【解决方案1】:

看看我的Github repository。它适用于 Elasticsearch 版本 2.4.6 的实例。

不幸的是,Spring Boot Starter Data Elasticsearch 尚不支持 Elasticsearch 版本 5.x,他们正在开发它,但您可以使用我的存储库,只需更改模型并使用您自己的方法更新存储库。

您的错误是因为您使用的是 Elasticsearch 5.x 实例并且您需要 2.x 版本。

【讨论】:

  • 我使用 elasticsearch-2.4.0 得到这个异常
  • 这是我从 localhost:9200 "version" : { "number" : "2.4.0", "build_hash" : "ce9f0c7394dee074091dd1bc4e9469251181fc55", "build_timestamp" : "2016-08-29T09:14:17Z", "build_snapshot" : false, "lucene_version" : "5.5.2" } 得到的
  • 非常感谢卡洛斯·巴斯克斯·洛萨达。我试图通过使用许多其他演示和教程一整天来使用 spring 数据运行 elasticsearch,然后我在这里找到了你的答案。它在一次尝试中工作,没有任何错误。
  • 你很高兴@vishalrana!我很高兴我的解决方案对您有用!!祝你有美好的一天!
【解决方案2】:

Spring 不支持最新版本的 elasticsearch 客户端。版本兼容性可以参考以下github repo

【讨论】:

    【解决方案3】:

    我知道晚了,但今天我遇到了同样的问题并解决了。我使用了与您使用的相同的东西。我一路尝试,但没有任何效果。 实际上,当您从 spring.initializer 下载 spring 项目时,它会在内部下载最新版本的弹性。如果您将鼠标悬停在 spring-boot-starter-data-elasticsearch 上,您可以看到它将从存储库中获取的弹性版本。

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
    

    所以为了解决这个问题你我改变了 Spring 的版本:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>**1.5.2.RELEASE**</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    

    然后右键单击您的项目并进行 maven 更新。它应该可以解决您的问题。

    【讨论】:

      【解决方案4】:

      你应该使用这个依赖

      <dependency>
          <groupId>org.apache.flink</groupId>
          <artifactId>flink-connector-elasticsearch5_2.12</artifactId>
          <version>1.7.2</version>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-29
        • 2022-07-19
        • 1970-01-01
        • 2018-08-25
        • 2020-09-20
        • 1970-01-01
        • 1970-01-01
        • 2020-01-11
        相关资源
        最近更新 更多