# Examples do not work. NoNodeAvailable but curl works

**URL:** <https://discuss.elastic.co/t/examples-do-not-work-nonodeavailable-but-curl-works/170964>\
**Category:** Elasticsearch\
**Created:** [March 5, 2019, 5:51pm UTC](https://discuss.elastic.co/t/examples-do-not-work-nonodeavailable-but-curl-works/170964 "2019-03-05T17:51:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steven/32/43164_2.png) [@Steven](https://discuss.elastic.co/u/Steven)\
**Post date:** [March 5, 2019, 5:51pm UTC](https://discuss.elastic.co/t/examples-do-not-work-nonodeavailable-but-curl-works/170964/1 "2019-03-05T17:51:42Z")

</div>

Just trying to play around with ES Java client.

I've cloned [https://github.com/elastic/examples/blob/master/Search/recipe\_search\_java/src/main/java/com/elastic/recipe/IndexRecipesApp.java#L43](https://github.com/elastic/examples/blob/master/Search/recipe_search_java/src/main/java/com/elastic/recipe/IndexRecipesApp.java#L43) and am running the docker image described in [https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile)

([https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile) + docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" [docker.elastic.co/elasticsearch/elasticsearch:6.6.1](http://docker.elastic.co/elasticsearch/elasticsearch:6.6.1)  
)

When running the example I get an error stating

```
 Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java (0x1092354c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1092b54e0). One of the two will be used. Which one is undefined.

```

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...  
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{0J\_3bgt7TvCAfDvAfehIqg}{127.0.0.1}{127.0.0.1:9300}]]  
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)  
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245)  
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:60)  
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:371)  
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:405)  
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:394)  
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:46)  
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:53)  
at com.elastic.recipe.IndexRecipesApp.main(IndexRecipesApp.java:53)

However when I do an insertion via curl everything works.

Can anyone advise what sillyness I'm doing. Google hasn't been particularly helpful.

I've tried turning sniffing on and off, and changing ports amongst other unsuccessful paths.

---

<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:** [March 5, 2019, 6:40pm UTC](https://discuss.elastic.co/t/examples-do-not-work-nonodeavailable-but-curl-works/170964/2 "2019-03-05T18:40:15Z")

</div>

Don't use the TransportClient but the rest client.

See [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html)

---

<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:** [April 2, 2019, 6:40pm UTC](https://discuss.elastic.co/t/examples-do-not-work-nonodeavailable-but-curl-works/170964/3 "2019-04-02T18:40:30Z")

</div>

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