# How to create “Hello World” node client of Elastic-Search in Java

**URL:** <https://discuss.elastic.co/t/how-to-create-hello-world-node-client-of-elastic-search-in-java/43324>\
**Category:** Elasticsearch\
**Created:** [March 3, 2016, 12:27am UTC](https://discuss.elastic.co/t/how-to-create-hello-world-node-client-of-elastic-search-in-java/43324 "2016-03-03T00:27:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ted.fed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ted.fed/32/56636_2.png) [@ted.fed](https://discuss.elastic.co/u/ted.fed)\
**Post date:** [March 3, 2016, 12:27am UTC](https://discuss.elastic.co/t/how-to-create-hello-world-node-client-of-elastic-search-in-java/43324/1 "2016-03-03T00:27:28Z")

</div>

Hi Group,

I have seen the docs at [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/node-client.htm](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/node-client.htm) but am not able to create a node client.

**Java file containing the code:**

import org.elasticsearch.action.index.IndexResponse;  
import org.elasticsearch.client.Client;  
import org.elasticsearch.common.settings.Settings;  
import org.elasticsearch.node.NodeBuilder;

public class EsRoutingNodeClient  
{  
private static final String ZEN\_DISCOVERY\_UNICAST\_HOSTS = "["10.10.10.10:9200"]"; // Used an actual ES master node's IP here  
private static final String ES\_PATH\_HOME = "/Users/appuser/work/software/elasticsearch/dummy-path-home/";  
private static final String ES\_CLUSTER\_NAME = "my-cluster";  
private Client client;

```
private void createEsClient ()
{
    Settings settings = Settings.settingsBuilder()
            .put("http.enabled", false)
            .put("discovery.zen.ping.multicast.enabled", false)
            .put("discovery.zen.ping.unicast.hosts", ZEN_DISCOVERY_UNICAST_HOSTS)
            .put("discovery.zen.minimum_master_nodes", 1)
            .put("path.home", ES_PATH_HOME)
            .build();
    client =
            NodeBuilder.nodeBuilder()
            .settings(settings)
            .clusterName(ES_CLUSTER_NAME)
            .data(false)
            .client(true)
            .node().client();
}

public EsRoutingNodeClient ()
{
    createEsClient();
}

public static void main (String args[])
{
    new EsRoutingNodeClient();
}

```

}

**pom.xml:**

\<?xml version="1.0" encoding="UTF-8"?\>

4.0.0  
examples  
es-node-client  
0.0.3-SNAPSHOT  
jar  
es-node-client  
  
\<project.build.sourceEncoding\>UTF-8\</project.build.sourceEncoding\>  
  
  
  
org.elasticsearch  
elasticsearch  
2.2.0  
  
  
  
  
  
org.apache.maven.plugins  
maven-shade-plugin  
2.4.3  
  
  
  
package  
  
shade  
  
  
  
  
org.slf4j:  
_com.esotericsoftware.kryo:kryo:_  
  
  
  
  
  
examples.EsRoutingNodeClient

**I run it as follows:**

mvn clean package  
java -jar target/es-node-client-0.0.3-SNAPSHOT.jar

**Exception I get is:**

1. Error injecting constructor, java.lang.IllegalStateException: This is a proxy used to support circular references involving constructors. The object we're proxying is not constructed yet. Please wait until after injection has completed to use this object.  
at org.elasticsearch.node.service.NodeService.(Unknown Source)  
while locating org.elasticsearch.node.service.NodeService  
for parameter 5 at org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction.(Unknown Source)  
while locating org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction  
for parameter 2 at org.elasticsearch.cluster.InternalClusterInfoService.(Unknown Source)

Caused by: java.lang.IllegalStateException: This is a proxy used to support circular references involving constructors. The object we're proxying is not constructed yet. Please wait until after injection has completed to use this object.  
at org.elasticsearch.common.inject.internal.ConstructionContext$DelegatingInvocationHandler.invoke(ConstructionContext.java:103)  
.... more lines  
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)  
at examples.EsRoutingNodeClient.createEsClient(EsRoutingNodeClient.java:30)  
at examples.EsRoutingNodeClient.(EsRoutingNodeClient.java:46)  
at examples.EsRoutingNodeClient.main(EsRoutingNodeClient.java:51)

---

<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:11pm UTC](https://discuss.elastic.co/t/how-to-create-hello-world-node-client-of-elastic-search-in-java/43324/2 "2017-07-05T23:11:51Z")

</div>


