# Cannot create bean because of ThreadPool in test environment

**URL:** <https://discuss.elastic.co/t/cannot-create-bean-because-of-threadpool-in-test-environment/153734>\
**Category:** Elasticsearch\
**Created:** [October 24, 2018, 7:22am UTC](https://discuss.elastic.co/t/cannot-create-bean-because-of-threadpool-in-test-environment/153734 "2018-10-24T07:22:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moonju](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@Moonju](https://discuss.elastic.co/u/Moonju)\
**Post date:** [October 24, 2018, 7:22am UTC](https://discuss.elastic.co/t/cannot-create-bean-because-of-threadpool-in-test-environment/153734/1 "2018-10-24T07:22:50Z")

</div>

Hi, I'm using ThreadPool to use BulkProcessor like this.

```
final Settings settings = Settings.builder().put(Node.NODE_NAME_SETTING, "high-level-client").build();
final ThreadPool threadPool = new ThreadPool(settings);

//getClient is returning RestHighLevelClient
//listener is BulkProcessor.Listener type

bulkProcessor = new BulkProcessor.Builder(getClient()::bulkAsync, listener, threadPool)
               .setBulkActions(100)

                       ...
               .build();

```

However, If I try to test, there is an exception

```
java.lang.IllegalStateException: Failed to load ApplicationContext
     ...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NAME': Invocation of init method failed; nested exception is java.lang.AssertionError
     ...
Caused by: java.lang.AssertionError
at org.elasticsearch.threadpool.ThreadPool.<init>(ThreadPool.java:163)
at CLASS_PATH.CLASS_NAME.init(CLASS_NAME.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

```

and CLASS\_NAME.java:100 is

```
final ThreadPool threadPool = new ThreadPool(settings);

```

How can I fix this problem?

I'm using Elasticsearch 5.6.12

---

<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:** [October 24, 2018, 9:53am UTC](https://discuss.elastic.co/t/cannot-create-bean-because-of-threadpool-in-test-environment/153734/2 "2018-10-24T09:53:55Z")

</div>

I wonder if you have another version of elasticsearch jar somewhere in your classpath...

---

<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 21, 2018, 9:53am UTC](https://discuss.elastic.co/t/cannot-create-bean-because-of-threadpool-in-test-environment/153734/3 "2018-11-21T09:53:58Z")

</div>

Closed on November 21, 2018, 9:53am UTC

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