# Elasticsearch Java Client Transport Client Exception

**URL:** <https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283>\
**Category:** Elasticsearch\
**Created:** [February 2, 2018, 9:10pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283 "2018-02-02T21:10:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)\
**Post date:** [February 2, 2018, 9:10pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/1 "2018-02-02T21:10:46Z")

</div>

Hello!

I'm trying to get the Elasticsearch Java SDK TransportClient Initialized, and I'm getting the following exception:

rg.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.common.settings.IndexScopedSettings  
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:982)

My POM looks like this since I'm using Maven:

```
<dependency>
   <groupId>org.elasticsearch</groupId>
   <artifactId>elasticsearch</artifactId>
   <version>6.0.1</version>
</dependency>
<dependency>
   <groupId>org.elasticsearch.client</groupId>
   <artifactId>transport</artifactId>
   <version>6.0.1</version>
</dependency>

```

Any help is appreciated!

---

<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:** [February 2, 2018, 9:25pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/2 "2018-02-02T21:25:48Z")

</div>

A wild guess is that this spring version is not compatible?

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)\
**Post date:** [February 2, 2018, 9:42pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/3 "2018-02-02T21:42:26Z")

</div>

Maybe, however I'm not sure why that would be the case. I'm not using spring-data-elasticsearch. Generally I'd say that unless I'm integrating with spring somehow, I haven't had any issues importing any other maven libraries.

---

<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:** [February 3, 2018, 4:51am UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/4 "2018-02-03T04:51:57Z")

</div>

Could you share more of your pom.xml and part of your code, ie. how you start elasticsearch?

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)\
**Post date:** [February 5, 2018, 4:29pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/5 "2018-02-05T16:29:26Z")

</div>

Here is my setup code. All parts of my code related to ES are in the original post, let me know what I may be missing.

```
  Settings settings = Settings.builder()
		        .put("cluster.name", this.clusterName)
		        .put("client.transport.sniff", true).build();
			
			lazy_client = new PreBuiltTransportClient(settings);
			lazy_client.addTransportAddress(new TransportAddress(InetAddress.getByName(this.clusterHost), this.clusterPort));
			return lazy_client;
```

---

<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:** [February 5, 2018, 4:41pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/6 "2018-02-05T16:41:48Z")

</div>

Could you just execute that code without Spring at all in a main() method?

The code looks good.

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)\
**Post date:** [February 5, 2018, 8:25pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/7 "2018-02-05T20:25:32Z")

</div>

I moved on to use the RestHighLevelClient since the TransportClient is being deprecated eventually. I never solved this issue.

---

<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:** [February 5, 2018, 10:08pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/8 "2018-02-05T22:08:17Z")

</div>

Great. But that was not my point.  
Could you reproduce the problem without Spring?

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Blayney](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeffrey\_Blayney](https://discuss.elastic.co/u/Jeffrey_Blayney)\
**Post date:** [February 8, 2018, 10:50pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/9 "2018-02-08T22:50:21Z")

</div>

Never tried it unfortunately, had to move on. I'm hard pressed to imagine how spring could cause the inability to find a class from a completely different maven library. If the issue does have something to do with spring, personally I'd call it a defect with the ES maven library, as an external dependency shouldn't cause class resolution problems.

Similar post (no maven though): [Could Not Initialize Class PreBuiltTransportClient](https://discuss.elastic.co/t/could-not-initialize-class-prebuilttransportclient/70097/4)

Personally my opinion is that we should just let the TransportClient get deprecated, ignore this issue as a very uncommon situation, and for anyone reading this post, they should move on to using the RestClient or RestHighLevelClient.

Thanks for your continued help and support!

---

<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:** [February 8, 2018, 11:09pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/10 "2018-02-08T23:09:50Z")

</div>

That's why I asked for this.  
I'd like to understand the cause and make sure nothing wierd is on our end.

---

<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:** [March 8, 2018, 11:10pm UTC](https://discuss.elastic.co/t/elasticsearch-java-client-transport-client-exception/118283/11 "2018-03-08T23:10:00Z")

</div>

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