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

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" -> "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.

The elasticsearch.yaml content of the els1 node:
cluster.name: multway
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.

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

private Client createClient(String hosts, String cluster) {
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;
}

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

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", cluster).build();

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

Were you able to solve this?

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

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

附上官方关于Transport与Node Client模式的区别:
https://www.elastic.co/guide/en/elasticsearch/guide/current/_transport_client_versus_node_client.html

please read the official document about it.

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

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

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