# Exception occurring when try to query a local elasticsearch node

**URL:** <https://discuss.elastic.co/t/exception-occurring-when-try-to-query-a-local-elasticsearch-node/26657>\
**Category:** Elasticsearch\
**Created:** [July 31, 2015, 7:11pm UTC](https://discuss.elastic.co/t/exception-occurring-when-try-to-query-a-local-elasticsearch-node/26657 "2015-07-31T19:11:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apanimesh061](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apanimesh061/32/927_2.png) [@apanimesh061](https://discuss.elastic.co/u/apanimesh061)\
**Post date:** [July 31, 2015, 7:11pm UTC](https://discuss.elastic.co/t/exception-occurring-when-try-to-query-a-local-elasticsearch-node/26657/1 "2015-07-31T19:11:56Z")

</div>

```
public class EsNode {
    private static File tempFile;
    private static File homeDir ;
    private static File confDir ;
    private static File dataDir ;
    private static Settings defaultSettings;

    private Node currentNode;

    public EsNode() {}

    public void init() throws IOException {
        try {
            tempFile = File.createTempFile("elasticSearchTest", "tmp");
            homeDir = new File(tempFile.getParent() + "/" + UUID.randomUUID().toString());
            confDir = new File(homeDir.getAbsolutePath() + "/config");
            dataDir = new File(homeDir.getAbsolutePath() + "/data");

            defaultSettings = ImmutableSettings
                    .settingsBuilder()
                    .put("node.http.enabled", false)
                    .put("http.enabled", false)
                    .put("cluster.name", "test_cluster")
                    .put("path.data", homeDir.getAbsolutePath())
                    .put("path.conf", confDir.getAbsolutePath())
                    .put("path.repo", homeDir.getAbsolutePath())
                    .put("script.disable_dynamic", false)
                    .put("index.refresh_interval", "1s")
                    .put("es.logger.level", "INFO")
                    .build();

            homeDir.deleteOnExit();
            confDir.deleteOnExit();
            dataDir.deleteOnExit();
            tempFile.deleteOnExit();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Client getClient() {
        return this.currentNode.client();
    }

    public void buildNode() {
        this.currentNode = nodeBuilder()
                .local(true)
                .data(true)
                .settings(defaultSettings)
                .build();
    }

    public void closeClient() {
        getClient().close();
    }

    public void ShutDown() {
        currentNode.close();
        if(currentNode.isClosed())
            System.out.println("Current running was closed.");
    }

    public void analyze() throws IOException {
         System.out.println(getClient().admin().indices().prepareExists("some_index").execute().actionGet().isExists());
    }

    public static void main(String[] args) throws IOException {
        EsNode esNode = new EsNode();
        esNode.init(); // create temporary stores/default settings
        esNode.buildNode(); // initialize node
        esNode.analyze(); // Error is raised here
        esNode.closeClient();
        esNode.ShutDown();
    }
}

```

This program raises this error:

```
Exception in thread "main" org.elasticsearch.common.util.concurrent.UncategorizedExecutionException: Failed execution
    at org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)
    at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:49)
    at edu.harvard.iq.text.core.service.node.EsNode.analyzeDocuments(EsNode.java:93)
    at edu.harvard.iq.text.core.service.node.EsNode.main(EsNode.java:132)
Caused by: java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:292)
    at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:279)
    at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:117)
    at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:45)
    ... 2 more
Caused by: java.lang.NullPointerException
    at org.elasticsearch.cluster.service.InternalClusterService.add(InternalClusterService.java:241)
    ... 12 more

```

What could be the issue?  
Thanks.

---

<div class="post-metadata">

**Author:** ![apanimesh061](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apanimesh061/32/927_2.png) [@apanimesh061](https://discuss.elastic.co/u/apanimesh061)\
**Post date:** [July 31, 2015, 11:43pm UTC](https://discuss.elastic.co/t/exception-occurring-when-try-to-query-a-local-elasticsearch-node/26657/2 "2015-07-31T23:43:48Z")

</div>

I found the issue.

`buildNode()` should have `this.currentNode = nodeBuilder().local(true).data(true).settings(defaultSettings).build().start();`.

To make it work I just added `start()` at the end.

---

<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:57pm UTC](https://discuss.elastic.co/t/exception-occurring-when-try-to-query-a-local-elasticsearch-node/26657/3 "2017-07-05T23:57:55Z")

</div>


