# Issue with changing the name of the cluster and the java API

**URL:** <https://discuss.elastic.co/t/issue-with-changing-the-name-of-the-cluster-and-the-java-api/51515>\
**Category:** Elasticsearch\
**Created:** [June 1, 2016, 6:36am UTC](https://discuss.elastic.co/t/issue-with-changing-the-name-of-the-cluster-and-the-java-api/51515 "2016-06-01T06:36:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![porous999](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@porous999](https://discuss.elastic.co/u/porous999)\
**Post date:** [June 1, 2016, 6:36am UTC](https://discuss.elastic.co/t/issue-with-changing-the-name-of-the-cluster-and-the-java-api/51515/1 "2016-06-01T06:36:35Z")

</div>

So, I have successfully set up ElasticSearch on my local system. And following is the code which I am trying to implement, based on [ES trasnport client](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html) client and [index example](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-index.html).

```
    String myClusterName = "mycluster";

    Settings settings = Settings.settingsBuilder()
        .put("cluster.name", myClusterName).build();
    settings = Settings.settingsBuilder()
            .put("client.transport.sniff", true).build();

    Client myClient = TransportClient.builder().build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("172.29.3.24"), 9300));
    try {
    IndexResponse clientresponse = myClient.prepareIndex("twitter", "tweet", "1")
        .setSource(jsonBuilder()
        .startObject()
        .field("user", "kimchy")
        .field("postDate", new Date())
        .field("message", "trying out Elasticsearch")
        .endObject()
        )
        .get();
    } catch (IOException e) {
	e.printStackTrace();
}

```

However when I am trying to run the example, I am getting the following error,

```
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{172.29.3.24}{172.29.3.24:9300}]]
    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)

```

The fun part is, if I start the cluster with the name _elasticsearch_ and use the same in the code, the code works fine. It only creates trouble when I try to use a customized cluster name. Any thoughts as to why this happens?

---

<div class="post-metadata">

**Author:** ![porous999](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@porous999](https://discuss.elastic.co/u/porous999)\
**Post date:** [June 1, 2016, 6:50am UTC](https://discuss.elastic.co/t/issue-with-changing-the-name-of-the-cluster-and-the-java-api/51515/2 "2016-06-01T06:50:11Z")

</div>

I have found the problem.... Issue is resolved... I had not passed the "setting" which I had created before the transport builder... After passing the parameter as follows, the issue was resolved.

```
    Client myClient = TransportClient.builder().settings(setting).build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("172.29.3.24"), 9300));
```

---

<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:** [June 1, 2016, 6:50am UTC](https://discuss.elastic.co/t/issue-with-changing-the-name-of-the-cluster-and-the-java-api/51515/3 "2016-06-01T06:50:15Z")

</div>

Instead of:

```auto
Settings settings = Settings.settingsBuilder()
        .put("cluster.name", myClusterName).build();
    settings = Settings.settingsBuilder()
            .put("client.transport.sniff", true).build();

```

Write:

```auto
Settings settings = Settings.settingsBuilder()
        .put("cluster.name", myClusterName)
        .put("client.transport.sniff", true)
        .build();

```

---

<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:47pm UTC](https://discuss.elastic.co/t/issue-with-changing-the-name-of-the-cluster-and-the-java-api/51515/4 "2017-07-05T22:47:25Z")

</div>


