# Elasticsearch Java API from web application-error: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.threadpool.ThreadPool

**URL:** <https://discuss.elastic.co/t/elasticsearch-java-api-from-web-application-error-java-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-threadpool-threadpool/68163>\
**Category:** Elasticsearch\
**Created:** [December 6, 2016, 11:33am UTC](https://discuss.elastic.co/t/elasticsearch-java-api-from-web-application-error-java-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-threadpool-threadpool/68163 "2016-12-06T11:33:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doln](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@doln](https://discuss.elastic.co/u/doln)\
**Post date:** [December 6, 2016, 11:33am UTC](https://discuss.elastic.co/t/elasticsearch-java-api-from-web-application-error-java-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-threadpool-threadpool/68163/1 "2016-12-06T11:33:43Z")

</div>

I have learned about elasticsearch. I have a problem as follow:  
I have installed elasticseach 2.4.1 on my project with maven:

```
<dependency>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>2.4.1</version>

```

```
<dependency>
         <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
         <version>18.0</version>
</dependency>

```

I create a class and using NodeClient

> Node node = NodeBuilder.nodeBuilder().settings(Settings.builder()  
> .put("path.home", "/path/to/elasticsearch/home/dir")).node();  
> org.elasticsearch.client.Client client = node.client();

Always after building the project at the first load the below error will appear:

> java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;

and after change guava library to version 19.0 or 20.0 then error appear:

> java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.threadpool.ThreadPool

I really appreciate you for sharing your knowledge.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 6, 2016, 1:01pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-from-web-application-error-java-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-threadpool-threadpool/68163/2 "2016-12-06T13:01:11Z")

</div>

Hi @doln,

it seems to me that you need to [shade the elasticsearch jar and all conflicting dependencies](https://www.elastic.co/blog/to-shade-or-not-to-shade).

Note: In Elasticsearch 5, we've created a new [REST client library](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html) which spares you that hassle. The REST client library is low-level at the moment but we [work on a high-level client](https://github.com/elastic/elasticsearch/issues/19055).

Daniel

---

<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:** [January 3, 2017, 1:01pm UTC](https://discuss.elastic.co/t/elasticsearch-java-api-from-web-application-error-java-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-threadpool-threadpool/68163/3 "2017-01-03T13:01:12Z")

</div>

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