# Elasticsearch-5.0.0-beta1 JAVA APINoNodeAvailableException

**URL:** <https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348>\
**Category:** Elasticsearch\
**Created:** [September 23, 2016, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348 "2016-09-23T08:55:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![VenkateshK](https://avatars.discourse-cdn.com/v4/letter/v/90ced4/32.png) [@VenkateshK](https://discuss.elastic.co/u/VenkateshK)\
**Post date:** [September 23, 2016, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/1 "2016-09-23T08:55:03Z")

</div>

I downloaded **Elasticsearch 5.0.0-beta1**. I am trying to add documents through JAVA API.

I always get exception when trying to run.

Elasticsearch configuration

```
cluster.name: cluster_hostname
node.name: node_venkatesh
network.host : ${HOSTNAME}
http.port: 9500
transport.tcp.port: 9700
script.engine.groovy.inline.aggs: on
script.engine.groovy.inline.update: on

```

JAVA API Configuration

```
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.client.Client;

Settings settings = null;
Client client = null;

this.settings = Settings.settingsBuilder()
				.put("cluster.name", "cluster_hostname")
				.put("client.transport.sniff", true)
				.put("node.name", "node_venkatesh")
				.put("transport.tcp.port", 9700).build();
this.client = TransportClient.builder().settings(settings).build().addTransportAddress(
			new InetSocketTransportAddress(InetAddress.getByName("HOSTNAME"), 9700));

```

Output when client is started

```
Sep 23, 2016 1:44:42 PM org.elasticsearch.plugins.PluginsService <init>
INFO: [node_venkatesh] modules [], plugins [], sites []
Sep 23, 2016 1:44:43 PM org.elasticsearch.client.transport.TransportClientNodesService$SniffNodesSampler$1$1 handleException
INFO: [node_venkatesh] failed to get local cluster state for {#transport#-1}{192.168. ***.*** }{HOSTNAME/192.168. ***.*** }, disconnecting...
NodeDisconnectedException[[][HOSTNAME/192.168. ***.*** :9700][cluster:monitor/state] disconnected]

```

Exception while running code

```
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{192.168. ***.*** }{HOSTNAME/192.168. ***.*** :9700}]]
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)
    at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
    at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
    at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)
    at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64)

```

This configuration and code is perfectly working with **elasticsearch-2.3.3**.

Kindly help.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [September 23, 2016, 12:32pm UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/2 "2016-09-23T12:32:15Z")

</div>

Hi @VenkateshK,

it seems you did not update the client, because the API has changed in 5.0.

This should get you going:

```auto
package org.elasticsearch.client.example;

import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Scratch {
    public static void main(String[] args) throws UnknownHostException {
        Settings settings = Settings.builder()
            .put("cluster.name", "your_cluster_name_here")
            .put("client.transport.sniff", true)
            .put("node.name", "sample_client_node")
            .put("transport.tcp.port", 9700).build();
        TransportClient client = new PreBuiltTransportClient(settings);
        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("your_cluster_ip_here"), 9700));

        final ClusterHealthResponse res = client.admin().cluster().health(new ClusterHealthRequest()).actionGet();
        System.out.println(res.getClusterName());
    }
}

```

Daniel

---

<div class="post-metadata">

**Author:** ![avneesh](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@avneesh](https://discuss.elastic.co/u/avneesh)\
**Post date:** [September 29, 2016, 9:15am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/3 "2016-09-29T09:15:19Z")

</div>

Hi @danielmitterdorfer ,  
Thanks for the sample code . I am trying your sample code with elasticsearch 5.0.0-beta1 version and I have following dependency included in my project . But it looks like this jar does not contain class **org.elasticsearch.transport.client.PreBuiltTransportClient**.  
Seems like jar present in maven is not up to date . Can you please point to the correct source from where I can download the jar for Elasticsearch-5.0.0-beat1 version.

`<dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>5.0.0-beta1</version> </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:** [September 29, 2016, 9:30am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/4 "2016-09-29T09:30:17Z")

</div>

Client ArtifactId changed. Read [https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.0/\_maven\_repository.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.0/_maven_repository.html)

---

<div class="post-metadata">

**Author:** ![avneesh](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@avneesh](https://discuss.elastic.co/u/avneesh)\
**Post date:** [September 29, 2016, 9:56am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/5 "2016-09-29T09:56:53Z")

</div>

Thanks, got it working

---

<div class="post-metadata">

**Author:** ![wlxwolves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wlxwolves/32/13774_2.png) [@wlxwolves](https://discuss.elastic.co/u/wlxwolves)\
**Post date:** [December 9, 2016, 10:13am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/6 "2016-12-09T10:13:00Z")

</div>

Hi, @danielmitterdorfer  
I don't understand what what should I set "node.name". Can I set any string to node.name or a specific name of node in ES cluster?

> ```
> .put("node.name", "sample_client_node")
> 
> ```

Thanks .

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 9, 2016, 10:28am UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/7 "2016-12-09T10:28:59Z")

</div>

Hi @wlxwolves,

this setting defines the "node" name of your transport client. You can set it to any value. However, you don't need to specify this setting necessarily. I just included it in my answer as it was also included in the question.

Daniel

---

<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:** [July 5, 2017, 10:05pm UTC](https://discuss.elastic.co/t/elasticsearch-5-0-0-beta1-java-apinonodeavailableexception/61348/8 "2017-07-05T22:05:09Z")

</div>


