# NoNodeAvailableException and endless stacktrace in log4j when using TransportClient

**URL:** <https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823>\
**Category:** Elasticsearch\
**Created:** [July 8, 2011, 7:32pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823 "2011-07-08T19:32:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimOnGmail](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@TimOnGmail](https://discuss.elastic.co/u/TimOnGmail)\
**Post date:** [July 8, 2011, 7:32pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823/1 "2011-07-08T19:32:43Z")

</div>

Hi all...

The following code, when I attempt to connect to a host that is down,  
throws a NoNodeAvailableException.

No problem there - however, in getting to that point ElasticSearch  
apparently recurses quite a lot, so that by the time it throws the  
Exception, the stack is so deep that log4j complains about it being  
too big, and I can't find the actual point of the problem...

* * *

try {  
TransportClient client = new  
TransportClient().addTransportAddress(new  
InetSocketTransportAddress(myHost, myPort);

```
  SearchRequestBuilder builder = client.prepareSearch(index,

```

## docType); builder.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH); builder.setQuery(new QueryStringQueryBuilder(queryString)); builder.setFrom(startIndex); builder.setSize(maxResults); builder.setExplain(true); ListenableActionFuture future = builder.execute(); } catch (Throwable t) { // EXCEPTION HERE }

If I just System.out.println() the caught exception, I see:  
-- org.elasticsearch.client.transport.NoNodeAvailableException: No  
node available

or if I call e.printStackTrace(), I see a reasonable-sized stacktrace.

However, if I try to print the stacktrace in log4j, I get:

java.lang.StackOverflowError  
at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)  
at java.lang.Throwable.toString(Throwable.java:343)  
at java.lang.String.valueOf(String.java:2826)  
at  
org.apache.log4j.spi.VectorWriter.println(ThrowableInformation.java:  
181)  
at java.lang.Throwable.printStackTrace(Throwable.java:509)  
at  
org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
67)  
at  
org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
99)  
at  
org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
99)

... ad infinitum.

I'm wondering what the stacktrace contains that might be causing  
this... possibly many branching "caused-by" entries? Anyone else seen  
this issue with log4j?

- Tim

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 8, 2011, 9:25pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823/2 "2011-07-08T21:25:17Z")

</div>

Do you have more stack trace when it happens in the log4j? See where the recursion happens?

On Friday, July 8, 2011 at 10:32 PM, TimOnGmail wrote:

> Hi all...
> 
> The following code, when I attempt to connect to a host that is down,  
> throws a NoNodeAvailableException.
> 
> No problem there - however, in getting to that point Elasticsearch  
> apparently recurses quite a lot, so that by the time it throws the  
> Exception, the stack is so deep that log4j complains about it being  
> too big, and I can't find the actual point of the problem...
> 
> * * *
> 
> try {  
> TransportClient client = new  
> TransportClient().addTransportAddress(new  
> InetSocketTransportAddress(myHost, myPort);
> 
> ## SearchRequestBuilder builder = client.prepareSearch(index, docType); builder.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH); builder.setQuery(new QueryStringQueryBuilder(queryString)); builder.setFrom(startIndex); builder.setSize(maxResults); builder.setExplain(true); ListenableActionFuture future = builder.execute(); } catch (Throwable t) { // EXCEPTION HERE }
> 
> If I just System.out.println() the caught exception, I see:  
> -- org.elasticsearch.client.transport.NoNodeAvailableException: No  
> node available
> 
> or if I call e.printStackTrace(), I see a reasonable-sized stacktrace.
> 
> However, if I try to print the stacktrace in log4j, I get:
> 
> java.lang.StackOverflowError  
> at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)  
> at java.lang.Throwable.toString(Throwable.java:343)  
> at java.lang.String.valueOf(String.java:2826)  
> at  
> org.apache.log4j.spi.VectorWriter.println(ThrowableInformation.java:  
> 181)  
> at java.lang.Throwable.printStackTrace(Throwable.java:509)  
> at  
> org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> 67)  
> at  
> org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> 99)  
> at  
> org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> 99)
> 
> ... ad infinitum.
> 
> I'm wondering what the stacktrace contains that might be causing  
> this... possibly many branching "caused-by" entries? Anyone else seen  
> this issue with log4j?
> 
> - Tim

---

<div class="post-metadata">

**Author:** ![TimOnGmail](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@TimOnGmail](https://discuss.elastic.co/u/TimOnGmail)\
**Post date:** [July 11, 2011, 7:50am UTC](https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823/3 "2011-07-11T07:50:57Z")

</div>

Unfortunately not - if I do a printStackTrace(), I see a reasonable  
stacktrace. But trying to print it with log4j gets the overflow  
error.

I'll can post the stacktrace that printStackTrace() returns if that's  
any help.

- Tim

On Jul 8, 2:25 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Do you have more stack trace when it happens in the log4j? See where the recursion happens?
> 
> On Friday, July 8, 2011 at 10:32 PM, TimOnGmail wrote:
> 
> > Hi all...
> 
> > The following code, when I attempt to connect to a host that is down,  
> > throws a NoNodeAvailableException.
> 
> > No problem there - however, in getting to that point Elasticsearch  
> > apparently recurses quite a lot, so that by the time it throws the  
> > Exception, the stack is so deep that log4j complains about it being  
> > too big, and I can't find the actual point of the problem...
> 
> > * * *
> > 
> > try {  
> > TransportClient client = new  
> > TransportClient().addTransportAddress(new  
> > InetSocketTransportAddress(myHost, myPort);
> 
> > ## SearchRequestBuilder builder = client.prepareSearch(index, docType); builder.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH); builder.setQuery(new QueryStringQueryBuilder(queryString)); builder.setFrom(startIndex); builder.setSize(maxResults); builder.setExplain(true); ListenableActionFuture future = builder.execute(); } catch (Throwable t) { // EXCEPTION HERE }
> 
> > If I just System.out.println() the caught exception, I see:  
> > -- org.elasticsearch.client.transport.NoNodeAvailableException: No  
> > node available
> 
> > or if I call e.printStackTrace(), I see a reasonable-sized stacktrace.
> 
> > However, if I try to print the stacktrace in log4j, I get:
> 
> > java.lang.StackOverflowError  
> > at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)  
> > at java.lang.Throwable.toString(Throwable.java:343)  
> > at java.lang.String.valueOf(String.java:2826)  
> > at  
> > org.apache.log4j.spi.VectorWriter.println(ThrowableInformation.java:  
> > 181)  
> > at java.lang.Throwable.printStackTrace(Throwable.java:509)  
> > at  
> > org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> > 67)  
> > at  
> > org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> > 99)  
> > at  
> > org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> > 99)
> 
> > ... ad infinitum.
> 
> > I'm wondering what the stacktrace contains that might be causing  
> > this... possibly many branching "caused-by" entries? Anyone else seen  
> > this issue with log4j?
> 
> > - Tim

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 11, 2011, 4:23pm UTC](https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823/4 "2011-07-11T16:23:16Z")

</div>

Got you, but, do you have more data printed as part of the stack overflow failure?

On Monday, July 11, 2011 at 10:50 AM, TimOnGmail wrote:

> Unfortunately not - if I do a printStackTrace(), I see a reasonable  
> stacktrace. But trying to print it with log4j gets the overflow  
> error.
> 
> I'll can post the stacktrace that printStackTrace() returns if that's  
> any help.
> 
> - Tim
> 
> On Jul 8, 2:25 pm, Shay Banon \<[shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) ([http://elasticsearch.com](http://elasticsearch.com))\> wrote:
> 
> > Do you have more stack trace when it happens in the log4j? See where the recursion happens?
> > 
> > On Friday, July 8, 2011 at 10:32 PM, TimOnGmail wrote:
> > 
> > > Hi all...
> > 
> > > The following code, when I attempt to connect to a host that is down,  
> > > throws a NoNodeAvailableException.
> > 
> > > No problem there - however, in getting to that point Elasticsearch  
> > > apparently recurses quite a lot, so that by the time it throws the  
> > > Exception, the stack is so deep that log4j complains about it being  
> > > too big, and I can't find the actual point of the problem...
> > 
> > > * * *
> > > 
> > > try {  
> > > TransportClient client = new  
> > > TransportClient().addTransportAddress(new  
> > > InetSocketTransportAddress(myHost, myPort);
> > 
> > > ## SearchRequestBuilder builder = client.prepareSearch(index, docType); builder.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH); builder.setQuery(new QueryStringQueryBuilder(queryString)); builder.setFrom(startIndex); builder.setSize(maxResults); builder.setExplain(true); ListenableActionFuture future = builder.execute(); } catch (Throwable t) { // EXCEPTION HERE }
> > 
> > > If I just System.out.println() the caught exception, I see:  
> > > -- org.elasticsearch.client.transport.NoNodeAvailableException: No  
> > > node available
> > 
> > > or if I call e.printStackTrace(), I see a reasonable-sized stacktrace.
> > 
> > > However, if I try to print the stacktrace in log4j, I get:
> > 
> > > java.lang.StackOverflowError  
> > > at java.lang.Throwable.getLocalizedMessage(Throwable.java:267)  
> > > at java.lang.Throwable.toString(Throwable.java:343)  
> > > at java.lang.String.valueOf(String.java:2826)  
> > > at  
> > > org.apache.log4j.spi.VectorWriter.println(ThrowableInformation.java:  
> > > 181)  
> > > at java.lang.Throwable.printStackTrace(Throwable.java:509)  
> > > at  
> > > org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> > > 67)  
> > > at  
> > > org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> > > 99)  
> > > at  
> > > org.apache.log4j.spi.ThrowableInformation.extractStringRep(ThrowableInformation.java:  
> > > 99)
> > 
> > > ... ad infinitum.
> > 
> > > I'm wondering what the stacktrace contains that might be causing  
> > > this... possibly many branching "caused-by" entries? Anyone else seen  
> > > this issue with log4j?
> > 
> > > - Tim

---

<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 6, 2017, 4:01am UTC](https://discuss.elastic.co/t/nonodeavailableexception-and-endless-stacktrace-in-log4j-when-using-transportclient/4823/5 "2017-07-06T04:01:02Z")

</div>


