# 'java.lang.StackOverflowError' exception. Cannot evaluate org.elasticsearch.common.inject.InjectorImpl.toString()

**URL:** <https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884>\
**Category:** Elasticsearch\
**Created:** [August 25, 2016, 4:22am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884 "2016-08-25T04:22:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [August 25, 2016, 4:22am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/1 "2016-08-25T04:22:01Z")

</div>

Hi, everyone.  
I have installed and configured the three ElasticSearch hosts with cluster.

It's OK when I use the HTTP API, but excepted when I use transport mode by Java client API.

The ElasticSearch server version is 2.3.4.

The exception happen like the following:  
injector = {org.elasticsearch.common.inject.InjectorImpl@3026} Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate org.elasticsearch.common.inject.InjectorImpl.toString()  
state = {org.elasticsearch.common.inject.InheritingState@3088}  
parent = null  
readOnly = true  
bindingsMultimap = {org.elasticsearch.common.inject.InjectorImpl$BindingsMultimap@3089}  
initializer = {org.elasticsearch.common.inject.Initializer@3090}  
jitBindings = {java.util.HashMap@3091} size = 0  
lookups = {org.elasticsearch.common.inject.InjectorImpl@3026} Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate org.elasticsearch.common.inject.InjectorImpl.toString()  
constructors = {org.elasticsearch.common.inject.ConstructorInjectorStore@3092}  
membersInjectorStore = {org.elasticsearch.common.inject.MembersInjectorStore@3093}  
localContext = {org.elasticsearch.common.inject.InjectorImpl$1@3094}

My hosts is:  
hosts = {java.lang.String@3022} "10.144.153.10:9300,10.163.250.111:9300,10.144.188.13:9300"  
cluster = {java.lang.String@3023} "multway"

The client settings is:  
settings = {com.google.common.collect.RegularImmutableSortedMap@3058} size = 7  
0 = {com.google.common.collect.ImmutableEntry@3064} "client.transport.sniff=false"  
1 = {com.google.common.collect.ImmutableEntry@3065} "client.type" -\> "transport"  
2 = {com.google.common.collect.ImmutableEntry@3066} "[cluster.name](http://cluster.name)" -\> "multway"  
3 = {com.google.common.collect.ImmutableEntry@3067} "name" -\> "Gravity"  
4 = {com.google.common.collect.ImmutableEntry@3068} "network.server" -\> "false"  
5 = {com.google.common.collect.ImmutableEntry@3069} "node.client" -\> "true"  
6 = {com.google.common.collect.ImmutableEntry@3070} "transport.ping\_schedule" -\> "5s"  
forcedUnderscoreSettings = {com.google.common.collect.EmptyImmutableBiMap@3059} size = 0

The cluster health status is green.  
{  
cluster\_name: "multway",  
status: "green",  
timed\_out: false,  
number\_of\_nodes: 3,  
number\_of\_data\_nodes: 3,  
active\_primary\_shards: 10,  
active\_shards: 20,  
relocating\_shards: 0,  
initializing\_shards: 0,  
unassigned\_shards: 0,  
delayed\_unassigned\_shards: 0,  
number\_of\_pending\_tasks: 0,  
number\_of\_in\_flight\_fetch: 0,  
task\_max\_waiting\_in\_queue\_millis: 0,  
active\_shards\_percent\_as\_number: 100  
}

Please give me some suggestions.  
Thanks.

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [August 25, 2016, 4:28am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/2 "2016-08-25T04:28:31Z")

</div>

The elasticsearch.yaml content of the els1 node:  
[cluster.name](http://cluster.name): multway  
[node.name](http://node.name): els1  
network.host: 0.0.0.0  
http.port: 9200  
transport.tcp.port: 9300  
discovery.zen.ping.multicast.enabled: false  
discovery.zen.ping.unicast.hosts: ["10.144.153.10:9300", "10.163.250.111:9300", "10.144.188.13:9300"]  
discovery.zen.minimum\_master\_nodes: 2

The others node's elasticsearch.yaml file content is similar except for the node name.

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [August 25, 2016, 5:24am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/3 "2016-08-25T05:24:53Z")

</div>

The following content is the source codes of the client side.

private Client createClient(String hosts, String cluster) {  
[logger.info](http://logger.info)("the elasticsearch host: " + hosts + ", cluster is " + cluster);

```
    Client client = null;
    try {
        TransportClient build = null;
        if(null != cluster && !cluster.trim().isEmpty()) {
            Settings settings = Settings.settingsBuilder()
                    .put("client.transport.sniff", false)
                    .put("cluster.name", cluster).build();
            build = TransportClient.builder().settings(settings).build();
            logger.info("initialized the cluster elasticsearch client settings!");
        } else {
            build = TransportClient.builder().build();
        }

        String[] hostArr = hosts.split(",");

        for(String item : hostArr) {
            String[] hps = item.split(":");

            String host = "127.0.0.1";
            Integer port = 9300;

            if(hps.length > 0) {
                host = hps[0];
            }

            if(hps.length > 1) {
                port = Integer.parseInt(hps[1]);
            }

            logger.info("the elasticsearch host is " + host + ", port is " + port);

            InetAddress address = null;

            String ipExp = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
            Pattern pat = Pattern.compile(ipExp);
            Matcher matcher = pat.matcher(host);

            if (matcher.matches()) {
                String[] segs = host.split("\\.");
                byte[] bs = new byte[]{Short.valueOf(segs[0]).byteValue(),
                        Short.valueOf(segs[1]).byteValue(),
                        Short.valueOf(segs[2]).byteValue(),
                        Short.valueOf(segs[3]).byteValue()};
                address = InetAddress.getByAddress(bs);
            } else {
                address = InetAddress.getByName(host);
            }

            build.addTransportAddress(new InetSocketTransportAddress(address, port));
        }

        client = build;
    } catch (UnknownHostException e) {
        logger.error("failed to initialize the elasticsearch client with the unknown host!", e);
    } catch (Exception e) {
        logger.error("failed to initialize the elasticsearch client!", e);
    }

    return client;
}
```

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 25, 2016, 7:09am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/4 "2016-08-25T07:09:14Z")

</div>

> [@popgis](#):
>
> "node.client" -\> "true"

This setting is for a node client, not for a transport client .

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [August 25, 2016, 3:01pm UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/5 "2016-08-25T15:01:28Z")

</div>

You means that I should create settings like this:  
Settings settings = Settings.settingsBuilder()  
.put("client.node", true)  
.put("client.transport.sniff", false)  
.put("[cluster.name](http://cluster.name)", cluster).build();

But It's not work still.  
The 'java.lang.StackOverflowError' exception exists.

---

<div class="post-metadata">

**Author:** ![kusid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kusid/32/13706_2.png) [@kusid](https://discuss.elastic.co/u/kusid)\
**Post date:** [December 29, 2016, 6:12pm UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/6 "2016-12-29T18:12:24Z")

</div>

Were you able to solve this?

---

<div class="post-metadata">

**Author:** ![skyfall](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@skyfall](https://discuss.elastic.co/u/skyfall)\
**Post date:** [February 21, 2017, 12:52am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/7 "2017-02-21T00:52:05Z")

</div>

我也遇到一样的问题了..你解决没？我es-2.4.4，配置也都差不多

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [February 21, 2017, 4:51am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/8 "2017-02-21T04:51:29Z")

</div>

应该还是服务器端运行模式的问题，可以试一下修改：  
client.node=false

附上官方关于Transport与Node Client模式的区别：  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/\_transport\_client\_versus\_node\_client.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/_transport_client_versus_node_client.html)

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [February 21, 2017, 4:52am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/9 "2017-02-21T04:52:50Z")

</div>

> [@popgis](#):
>
> [Transport Client Versus Node Client | Elasticsearch: The Definitive Guide [2.x] | Elastic](https://www.elastic.co/guide/en/elasticsearch/guide/current/_transport_client_versus_node_client.html)

please read the official document about it.

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [February 21, 2017, 4:59am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/10 "2017-02-21T04:59:22Z")

</div>

> [@jprante](#):
>
> node.client

还有一个客户端设置需要注意：  
Settings settings = Settings.settingsBuilder()  
.put("client.transport.sniff", true)

---

<div class="post-metadata">

**Author:** ![popgis](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@popgis](https://discuss.elastic.co/u/popgis)\
**Post date:** [February 21, 2017, 5:00am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/11 "2017-02-21T05:00:25Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html)

---

<div class="post-metadata">

**Author:** ![skyfall](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@skyfall](https://discuss.elastic.co/u/skyfall)\
**Post date:** [February 21, 2017, 6:16am UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/12 "2017-02-21T06:16:32Z")

</div>

谢谢哥们啊 设置我没改动 忽略这个问题 继续跑下去 就能获取结果 这个溢出放着了

---

<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:03pm UTC](https://discuss.elastic.co/t/java-lang-stackoverflowerror-exception-cannot-evaluate-org-elasticsearch-common-inject-injectorimpl-tostring/58884/13 "2017-07-05T22:03:03Z")

</div>


