# Getting availableProcessors is already set to \[1\], rejecting \[1\] IllegalStateException exception

**URL:** <https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082>\
**Category:** Elasticsearch\
**Created:** [October 6, 2017, 9:11pm UTC](https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082 "2017-10-06T21:11:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit\_Nigam](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@Rohit\_Nigam](https://discuss.elastic.co/u/Rohit_Nigam)\
**Post date:** [October 6, 2017, 9:11pm UTC](https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082/1 "2017-10-06T21:11:40Z")

</div>

Hi I am using transport client to connect to the elastic search cluster and getting this exception

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at com.slb.index.core.IndexServiceHandler.processDataAndSchemaForElastic(IndexServiceHandler.java:1824) at com.slb.index.core.IndexServiceHandler.processClubbedList(IndexServiceHandler.java:1774) ... 28 more Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at com.slb.index.util.TransportClientHandle.getTransportClient(TransportClientHandle.java:43) at com.slb.index.core.IndexServiceHandler.processElasticSchema(IndexServiceHandler.java:1935) at com.slb.index.core.IndexServiceHandler.processDataAndSchemaForElastic(IndexServiceHandler.java:1816) ... 29 more Caused by: java.lang.IllegalStateException: availableProcessors is already set to [1], rejecting [1] at io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51) at io.netty.util.NettyRuntime.setAvailableProcessors(NettyRuntime.java:87) at org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:82) at org.elasticsearch.transport.netty4.Netty4Transport.(Netty4Transport.java:138) at org.elasticsearch.transport.Netty4Plugin.lambda$getTransports$0(Netty4Plugin.java:93) at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:174) at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:265) at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:130) at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:116) at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:106) at com.slb.index.util.TransportClientHandle.getTransportClient(TransportClientHandle.java:38) ... 31 more

I am using elastic search 5.5.0 and this is the way i connect to ES

public static TransportClient getTransportClient(){  
TransportClient client = null;  
try{  
Settings settings = Settings.builder()  
.put("client.transport.sniff",true)  
.put("[cluster.name](http://cluster.name)", System.getenv(SharedConstant.CLUSTER))  
.build();  
client = new PreBuiltTransportClient(settings)  
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(System.getenv(SharedConstant.HOST1)), 9300))  
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(System.getenv(SharedConstant.HOST2)), 9300));  
}catch (Exception e){  
[LOG.info](http://LOG.info)(e.getMessage());  
throw new RuntimeException(e);

```
        }
        return client;
    }

```

Any help in resolving this would be appreciated.  
Rohit

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [October 7, 2017, 5:12pm UTC](https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082/2 "2017-10-07T17:12:38Z")

</div>

I think that you’re using Netty elsewhere in your application, yes? If so, you have two choices:

- force the transport client to initialize before any other component that uses Netty initializes
- set the system property `es.set.netty.runtime.available.processors` to `false`

You should prefer the first option, the second option is an escape hatch.

---

<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:** [November 4, 2017, 5:13pm UTC](https://discuss.elastic.co/t/getting-availableprocessors-is-already-set-to-1-rejecting-1-illegalstateexception-exception/103082/3 "2017-11-04T17:13:14Z")

</div>

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