# NoNodeAvailableException -- Java API

**URL:** https://discuss.elastic.co/t/nonodeavailableexception-java-api/34645
**Category:** Elasticsearch
**Created:** [November 16, 2015, 6:33am UTC](https://discuss.elastic.co/t/nonodeavailableexception-java-api/34645 "2015-11-16T06:33:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Carlos\_Vega\_Moreno](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_vega_moreno/32/3773_2.png) [@Carlos\_Vega\_Moreno](https://discuss.elastic.co/u/Carlos_Vega_Moreno)
#### Post date: [November 16, 2015, 6:33am UTC](https://discuss.elastic.co/t/nonodeavailableexception-java-api/34645/1 "2015-11-16T06:33:06Z")

</div>

After connecting to the elasticsearch cluster through the Java API I get an error. These are the lines that proof I'm able to connect to the node. The IP is correct, I just replaced with xxx. But when I try to create a mapping I get an error. This problem occurs only with the new elasticsearch 2 and the new java api.

> 2015-11-11 11:04:36.987 Getting ES Client...  
> Nov 11, 2015 11:04:37 AM org.elasticsearch.plugins.PluginsService   
> INFO: [Elfqueen] loaded , sites   
> 2015-11-11 11:04:36.987 Node: xxx.xxx.xxx.xxx  
> 2015-11-11 11:04:36.987 ES Client obtained

I'm not able to create a new mapping in the cluster because I get this error on the last line of this piece of code:

```
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(indexName);
createIndexRequestBuilder.addMapping(documentName, json);
createIndexRequestBuilder.execute().actionGet();

```

> Exception in thread "Thread-1" NoNodeAvailableException[None of the configured nodes are available:]  
> at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:280)  
> at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:197)  
> at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)  
> at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)  
> at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)  
> at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1177)  
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)  
> at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)

Is the same code that I used with previous versions of the Java API but I didn't get any errors then. I get the ES client with this code:

```
private static Client getClient() {  
        Settings settings = Settings.settingsBuilder().build();
        Client client = null;
        TransportClient transportClient = TransportClient.builder().settings(settings).build();

        try {
            client = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(Receptor.es_ip), 9300));
        } catch (UnknownHostException e) {
            System.err.println(Util.getTimestampStr() + "UnknownHostException error.");
            e.printStackTrace();
        }

        if(transportClient.connectedNodes() == null){
            System.err.println(Util.getTimestampStr() + "No connected nodes found.");
        }else{
            for(DiscoveryNode d : transportClient.connectedNodes()){
                System.err.println(Util.getTimestampStr() + "DiscoveryNode: " + d.getHostName());
            }
            for(DiscoveryNode d : transportClient.listedNodes()){
                System.err.println(Util.getTimestampStr() + "Node: " + d.getHostName());
            }
        }
    
        return transportClient;
    }

```

---

<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, 11:38pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-java-api/34645/2 "2017-07-05T23:38:17Z")

</div>


