# Problem with ES5 TransportClient

**URL:** <https://discuss.elastic.co/t/problem-with-es5-transportclient/66749>\
**Category:** Elasticsearch\
**Created:** [November 21, 2016, 3:47pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749 "2016-11-21T15:47:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosec](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@cosec](https://discuss.elastic.co/u/cosec)\
**Post date:** [November 21, 2016, 3:47pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749/1 "2016-11-21T15:47:53Z")

</div>

Hello,  
I'm trying to do the simplest thing- create a TransportClient for ES5.0.  
My POM file:

```
<dependencies>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>5.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.6.2</version>
    </dependency>
</dependencies>

```

And my Java code looks like this:

```
public class EsTest {
    private static final Logger logger = LogManager.getLogger("EsTest");
    private static TransportClient client;

    public static void main(String[] args) {
        Settings settings = Settings.builder().put("cluster.name", "myCluster").put("client.transport.sniff", true).build();
        TransportClient client = new PreBuiltTransportClient(settings);
    .
    .
    .
    }
}

```

Yet right after the line:

> TransportClient client = new PreBuiltTransportClient(settings);

I get:

> client.injector = Method threw 'java.lang.StackOverflowError' exception. Cannot evaluate org.elasticsearch.common.inject.InjectorImpl.toString().

(Settings.EMPTY has the same effect)

Why is this happening?

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 21, 2016, 3:55pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749/2 "2016-11-21T15:55:09Z")

</div>

Hi,

has your project resolved the transitive dependencies of the transport client correctly. Judging from the [pom](https://repo1.maven.org/maven2/org/elasticsearch/client/transport/5.0.1/transport-5.0.1.pom) in maven central, it depends on the main elasticsearch jar. I suspect this is missing somehow in your ides project setup.

---

<div class="post-metadata">

**Author:** ![cosec](https://avatars.discourse-cdn.com/v4/letter/c/858c86/32.png) [@cosec](https://discuss.elastic.co/u/cosec)\
**Post date:** [November 21, 2016, 4:06pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749/3 "2016-11-21T16:06:07Z")

</div>

Hi and thanks for the quick reply.  
I have tried adding this to my POM:

```
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>5.0.1</version>
</dependency>

```

Did not help.. ☹

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [November 21, 2016, 4:39pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749/4 "2016-11-21T16:39:24Z")

</div>

I'm not sure where the injector error comes from but I just set up a minimal maven project with only the transport client dependency in eclipse. This already pulls the core dependency as expected. I'm able to connect to a local cluster via TransportClient like this:

```auto
public static void main(String[] args) throws InterruptedException, ExecutionException, UnknownHostException {
        Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("client.transport.sniff", true).build();
        TransportClient client = new PreBuiltTransportClient(settings);
        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
        SearchResponse searchResponse = client.prepareSearch("index").execute().get();
        System.out.println(searchResponse);
        client.close();
    }

```

Since your code snippet is missing some parts and the stack trace is also not complete it is hard to guess what's wrong on your end. Maybe you can provide more information about your setup or try an even more minimal setup to at least get a simple connection going. It should be possible as I just checked myself.

---

<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:** [November 21, 2016, 4:50pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749/5 "2016-11-21T16:50:09Z")

</div>

@cosec do you have other Elasticsearch jars on your runtime class path?

---

<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:** [December 19, 2016, 4:50pm UTC](https://discuss.elastic.co/t/problem-with-es5-transportclient/66749/6 "2016-12-19T16:50:16Z")

</div>

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