# njava.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.xcontent.json.JsonXContent

**URL:** <https://discuss.elastic.co/t/njava-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-xcontent-json-jsonxcontent/349373>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 14, 2023, 2:08pm UTC](https://discuss.elastic.co/t/njava-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-xcontent-json-jsonxcontent/349373 "2023-12-14T14:08:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jhalak43](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@Jhalak43](https://discuss.elastic.co/u/Jhalak43)\
**Post date:** [December 14, 2023, 2:08pm UTC](https://discuss.elastic.co/t/njava-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-xcontent-json-jsonxcontent/349373/1 "2023-12-14T14:08:18Z")

</div>

Previously we were using 7.17.12 version of below dependency  
  
org.elasticsearch  
elasticsearch

But now when i update version from 7.17.12 to 8.6.1 or 8.8.2 i get below exception  
Could not initialize class org.elasticsearch.xcontent.json.JsonXContent","exception":"\njava.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.xcontent.json.JsonXContent

this error comes up while trying to access toString method for searchSourceBuilder , SortBuilder & AbstractQueryBuilder. Also the class searchSourceBuilder is declared as final so the same could not extended to override its toString method. Can anyone please suggest how can we convert these models to string format.

---

<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 11, 2024, 2:09pm UTC](https://discuss.elastic.co/t/njava-lang-noclassdeffounderror-could-not-initialize-class-org-elasticsearch-xcontent-json-jsonxcontent/349373/2 "2024-01-11T14:09:05Z")

</div>

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