# Guice Creation Error

**URL:** <https://discuss.elastic.co/t/guice-creation-error/19059>\
**Category:** Elasticsearch\
**Created:** [August 3, 2014, 10:42pm UTC](https://discuss.elastic.co/t/guice-creation-error/19059 "2014-08-03T22:42:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![esuser](https://avatars.discourse-cdn.com/v4/letter/e/f9ae1b/32.png) [@esuser](https://discuss.elastic.co/u/esuser)\
**Post date:** [August 3, 2014, 10:42pm UTC](https://discuss.elastic.co/t/guice-creation-error/19059/1 "2014-08-03T22:42:31Z")

</div>

Hi,

We are using Spring Framework with elasticsearch.

_ES Version_ : 1.2.1

_Code_

Client client = new TransportClient().addTransportAddress(new  
InetSocketTransportAddress(url, 9300));

SearchResponse response = client.prepareSearch(""escore")  
.addAggregation(AggregationBuilders.cardinality("CUSTOMER").field("CUSTOMER"))  
.setSize(0).execute().actionGet();  
client.close();

It works fine for fist few hits , After that it throws below  
exception. Is there any thing wrong with the code. Really appreciate  
any pointers/help on this.

java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: \*Guice  
creation errors:  
\*

1. Error injecting constructor, _java.lang.OutOfMemoryError: unable to  
create new native thread_  
at org.elasticsearch.threadpool.ThreadPool.(Unknown Source)  
while locating org.elasticsearch.threadpool.ThreadPool_Caused by:  
java.lang.OutOfMemoryError: unable to create new native thread_  
at java.lang.Thread.start0(Native Method)  
at java.lang.Thread.start(Thread.java:713)  
at org.elasticsearch.threadpool.ThreadPool.(ThreadPool.java:144)  
at sun.reflect.GeneratedConstructorAccessor69.newInstance(Unknown Source)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)  
at org.elasticsearch.common.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:54)  
at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:86)  
at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)  
at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)  
at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:837)  
at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)  
at org.elasticsearch.common.inject.Scopes$1$1.get(Scopes.java:57)  
at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)  
at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:200)  
at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:193)  
at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:830)  
at org.elasticsearch.common.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:193)  
at org.elasticsearch.common.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:175)  
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:110)  
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)  
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)  
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:187)  
_at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:117)_

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAJfX5E2rVXE7eVe08JTkgx8rpmOQPsFCjUdEgrxz8rZuurBEog%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJfX5E2rVXE7eVe08JTkgx8rpmOQPsFCjUdEgrxz8rZuurBEog%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 3, 2014, 11:38pm UTC](https://discuss.elastic.co/t/guice-creation-error/19059/2 "2014-08-03T23:38:46Z")

</div>

Do you create a new client for each request?  
If so, create only one client when your application start.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 4 août 2014 à 00:42, Subacini B [subacini@gmail.com](mailto:subacini@gmail.com) a écrit :

Hi,

We are using Spring Framework with elasticsearch.

ES Version : 1.2.1  
Code

Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress(url, 9300));

SearchResponse response = client.prepareSearch(""escore")  
.addAggregation(AggregationBuilders.cardinality("CUSTOMER").field("CUSTOMER"))  
.setSize(0).execute().actionGet();

```
	client.close();

```

It works fine for fist few hits , After that it throws below exception. Is there any thing wrong with the code. Really appreciate any pointers/help on this.

java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Guice creation errors:

1. Error injecting constructor, java.lang.OutOfMemoryError: unable to create new native thread  
at org.elasticsearch.threadpool.ThreadPool.(Unknown Source)  
while locating org.elasticsearch.threadpool.ThreadPool  
Caused by: java.lang.OutOfMemoryError: unable to create new native thread  
at java.lang.Thread.start0(Native Method)  
at java.lang.Thread.start(Thread.java:713)  
at org.elasticsearch.threadpool.ThreadPool.(ThreadPool.java:144)  
at sun.reflect.GeneratedConstructorAccessor69.newInstance(Unknown Source)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)  
at org.elasticsearch.common.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:54)  
at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:86)  
at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:98)  
at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)  
at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:837)  
at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)  
at org.elasticsearch.common.inject.Scopes$1$1.get(Scopes.java:57)  
at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)  
at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:200)  
at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:193)  
at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:830)  
at org.elasticsearch.common.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:193)  
at org.elasticsearch.common.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:175)  
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:110)  
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)  
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)  
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:187)  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:117)  
--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAJfX5E2rVXE7eVe08JTkgx8rpmOQPsFCjUdEgrxz8rZuurBEog%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJfX5E2rVXE7eVe08JTkgx8rpmOQPsFCjUdEgrxz8rZuurBEog%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/D2EB8DCB-6E3B-4324-981F-22273EE46808%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/D2EB8DCB-6E3B-4324-981F-22273EE46808%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:11am UTC](https://discuss.elastic.co/t/guice-creation-error/19059/3 "2017-07-06T01:11:19Z")

</div>


