# Spring Data ElasticSearch Can't Connect with ElasticSearch 5.5.0

**URL:** <https://discuss.elastic.co/t/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0/94235>\
**Category:** Elasticsearch\
**Created:** [July 23, 2017, 10:33am UTC](https://discuss.elastic.co/t/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0/94235 "2017-07-23T10:33:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![halogeek](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@halogeek](https://discuss.elastic.co/u/halogeek)\
**Post date:** [July 23, 2017, 10:33am UTC](https://discuss.elastic.co/t/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0/94235/1 "2017-07-23T10:33:42Z")

</div>

Am new to ElasticSearch...

Really love the API (especially ElasticsearchTemplate & supporting Unit Tests)...

Was following this example using ElasticSearch 5.5.0 (the following link has the full code inline and also available as a downloadable zip file):

[https://www.mkyong.com/spring-boot/spring-boot-spring-data-elasticsearch-example/](https://www.mkyong.com/spring-boot/spring-boot-spring-data-elasticsearch-example/)

maven dependencies:

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

<properties>
    <java.version>1.8</java.version>
</properties>

<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>
</dependencies>

```

EsConfig:

```
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.mkyong.book.repository")
public class EsConfig {

    @Value("${elasticsearch.host}")
    private String EsHost;

    @Value("${elasticsearch.port}")
    private int EsPort;

    @Value("${elasticsearch.clustername}")
    private String EsClusterName;

    @Bean
    public Client client() throws Exception {

        Settings esSettings = Settings.settingsBuilder()
                .put("cluster.name", EsClusterName)
                .build();

        //https://www.elastic.co/guide/en/elasticsearch/guide/current/_transport_client_versus_node_client.html
        return TransportClient.builder()
                .settings(esSettings)
                .build()
                .addTransportAddress(
                  new InetSocketTransportAddress(InetAddress.getByName(EsHost), EsPort));
    }

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(client());
    }
}

```

src/main/resources:

```
elasticsearch.clustername = mkyong-cluster
elasticsearch.host = localhost
elasticsearch.port = 9300

```

When issuing the following, either:

```
mvn spring-boot:run

```

or

```
mvn clean test

```

stdout:

```
Caused by: 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)
   at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:223)
   at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)

```

Also, get the following in my ElasticSearch 5.5.0 engine's stdout:

```
[2017-07-23T02:48:46,135][WARN][o.e.t.n.Netty4Transport] [vY7jxpr] exception caught on transport layer [[id: 0xa7e950be, L:/127.0.0.1:9300 - R:/127.0.0.1:60190]], closing connection
    java.lang.IllegalStateException: Received message from unsupported version: [1.0.0] minimal compatible version is: [5.0.0]
        at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1379) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:74) ~[transport-netty4-5.5.0.jar:5.5.0]    

```

Is there any way to use Spring Data ElasticSearch with ElasticSearch 5.5.0 engine?

If so, how would the connection be implemented?

I am using the Elastic Search Java client provided by Elastic Search and am able to connect and create indices on ElasticSearch 5.5.0 but really wish I could use the power of this library.

---

<div class="post-metadata">

**Author:** ![ahmadimt07](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmadimt07/32/10031_2.png) [@ahmadimt07](https://discuss.elastic.co/u/ahmadimt07)\
**Post date:** [July 23, 2017, 3:02pm UTC](https://discuss.elastic.co/t/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0/94235/2 "2017-07-23T15:02:22Z")

</div>

The Spring boot 1.5.1.RELEASE does not support ElasticSearch 5.x. Please refer the following link for the supported version of ES.

[http://docs.spring.io/spring-boot/docs/1.5.1.RELEASE/reference/html/appendix-dependency-versions.html](http://docs.spring.io/spring-boot/docs/1.5.1.RELEASE/reference/html/appendix-dependency-versions.html)

Moreover, If you are starting fresh, then it's better to use Java REST client. Here is a blog that  
[https://www.elastic.co/blog/state-of-the-official-elasticsearch-java-clients](https://www.elastic.co/blog/state-of-the-official-elasticsearch-java-clients) that talks about different clients.

The following examples shows how to use ES Java rest client with Spring boot.

> **[The new elasticsearch java Rest Client - Luminis Amsterdam](https://amsterdam.luminis.eu/2016/07/07/the-new-elasticsearch-java-rest-client/)**
>
> With the latest release of elasticsearch 5.0.0 alpha 4, a new client for java is introduced. The idea behind this new client is less dependencies on elasticsearch. At the moment you have to include the complete elasticsearch distributable with even a...

---

<div class="post-metadata">

**Author:** ![halogeek](https://avatars.discourse-cdn.com/v4/letter/h/c37758/32.png) [@halogeek](https://discuss.elastic.co/u/halogeek)\
**Post date:** [July 23, 2017, 7:22pm UTC](https://discuss.elastic.co/t/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0/94235/3 "2017-07-23T19:22:45Z")

</div>

According to the same question I posted on Stack Overflow:

> <https://stackoverflow.com/questions/45264023/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0>

> Spring Boot 1.5.1 does not support Elasticsearch 5.x (the article you provided also says it). To make it possible to work with Elasticsearch 5.x you need to use a milestone of Spring Boot 2.

> Try to configure your project with following dependencies:

> # spring boot
> 
> compile 'org.springframework.boot:spring-boot:2.0.0.M2'

> # elasticsearch
> 
> compile 'org.elasticsearch:elasticsearch:5.5.0'  
> compile 'org.elasticsearch.client:transport:5.5.0'

> # spring-data-elasticsearch for spring boot
> 
> compile 'org.springframework.boot:spring-boot-starter-data-elasticsearch:2.0.0.M2'  
> This should allow you to use all the goodies of Elasticsearch Java API ans spring-data-elasticsearch.

Is this true? However, I am a maven person so if this is true, can someone send me an example pom.xml that resembles the dependencies (including repositories) for the milestones?

---

<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:** [August 20, 2017, 7:23pm UTC](https://discuss.elastic.co/t/spring-data-elasticsearch-cant-connect-with-elasticsearch-5-5-0/94235/4 "2017-08-20T19:23:11Z")

</div>

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