# Create elasticsearch client throws netty illegalstateexception in server enviroment

**URL:** <https://discuss.elastic.co/t/create-elasticsearch-client-throws-netty-illegalstateexception-in-server-enviroment/176809>\
**Category:** Elasticsearch\
**Created:** [April 15, 2019, 2:52am UTC](https://discuss.elastic.co/t/create-elasticsearch-client-throws-netty-illegalstateexception-in-server-enviroment/176809 "2019-04-15T02:52:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dodolzg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dodolzg/32/44110_2.png) [@dodolzg](https://discuss.elastic.co/u/dodolzg)\
**Post date:** [April 15, 2019, 2:52am UTC](https://discuss.elastic.co/t/create-elasticsearch-client-throws-netty-illegalstateexception-in-server-enviroment/176809/1 "2019-04-15T02:52:02Z")

</div>

The error info

> Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]  
> at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)  
> at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)  
> ... 112 more  
> Caused by: java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]  
> 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:85)  
> at org.elasticsearch.transport.netty4.Netty4Transport.(Netty4Transport.java:140)  
> at org.elasticsearch.transport.Netty4Plugin.lambda$getTransports$0(Netty4Plugin.java:93)  
> at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:177)  
> at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:257)

And I add "System.setProperty("es.set.netty.runtime.available.processors", "false");"  
`public static void main(final String[] args) {`  
`System.setProperty("es.set.netty.runtime.available.processors", "false");`  
`SpringApplication springApplication = new SpringApplication(Application.class);`  
`springApplication.addListeners(new ApplicationPidFileWriter("sns.pid"));`  
`springApplication.run(args);`  
`}`

It works in my local enviroment(oracle jdk1.8), but does not work in server  
enviroment(openjdk1.8).  
I am not sure whether the jdk version matters? If not, how to solve the error?Thanks.

OS: Centos  
Springboot: 2.0.6  
Elasticsearch: 6.3.1

Maven dependency

> ```
> <dependency>
> 
> ```

```
    <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        <version>2.0.6.RELEASE</version>
    </dependency>

```

Application.properties

> spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300  
> spring.data.elasticsearch.cluster-name=elasticsearch  
> spring.data.elasticsearch.repositories.enabled=true

---

<div class="post-metadata">

**Author:** ![dodolzg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dodolzg/32/44110_2.png) [@dodolzg](https://discuss.elastic.co/u/dodolzg)\
**Post date:** [April 15, 2019, 3:29am UTC](https://discuss.elastic.co/t/create-elasticsearch-client-throws-netty-illegalstateexception-in-server-enviroment/176809/2 "2019-04-15T03:29:25Z")

</div>

Finally I added the parameters in the start bash, and it worked.

> -Des.set.netty.runtime.available.processors=false

I thought that the main function code 'System.setProperty("es.set.netty.runtime.available.processors", "false");' should be loaded first.

---

<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:** [May 13, 2019, 3:29am UTC](https://discuss.elastic.co/t/create-elasticsearch-client-throws-netty-illegalstateexception-in-server-enviroment/176809/3 "2019-05-13T03:29:39Z")

</div>

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