Cannot create bean because of ThreadPool in test environment

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

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

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