# Getting this error java.lang.ClassNotFoundException: jakarta.json.JsonException

**URL:** <https://discuss.elastic.co/t/getting-this-error-java-lang-classnotfoundexception-jakarta-json-jsonexception/306734>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 8, 2022, 5:55pm UTC](https://discuss.elastic.co/t/getting-this-error-java-lang-classnotfoundexception-jakarta-json-jsonexception/306734 "2022-06-08T17:55:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhavya\_Dawar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavya_dawar/32/101132_2.png) [@Bhavya\_Dawar](https://discuss.elastic.co/u/Bhavya_Dawar)\
**Post date:** [June 8, 2022, 5:55pm UTC](https://discuss.elastic.co/t/getting-this-error-java-lang-classnotfoundexception-jakarta-json-jsonexception/306734/1 "2022-06-08T17:55:49Z")

</div>

Failed to instantiate [co.elastic.clients.Elasticsearch.ElasticsearchClient]: Factory method 'client' threw exception; nested exception is java.lang.NoClassDefFoundError: jakarta/json/JsonException

@Bean  
public ElasticsearchClient client() throws Exception {  
RestClient restClient = RestClient.builder(  
new HttpHost(esHost, esPort)).build();

```
   // Create the transport with a Jackson mapper
    ElasticsearchTransport transport = new RestClientTransport(
            restClient, new JacksonJsonpMapper());

    // And create the API client
    return new ElasticsearchClient(transport);
}

```

Dependency:

 org.springframework.boot spring-boot-starter-web 2.6.7 

```
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-jpa</artifactId>
		<version>2.6.7</version>
	</dependency>
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>8.0.29</version>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-redis</artifactId>
		<version>2.6.7</version>
	</dependency>
	<dependency>
		<groupId>redis.clients</groupId>
		<artifactId>jedis</artifactId>
		<version>4.2.3</version>
	</dependency>

	<dependency>
		<groupId>com.paytm</groupId>
		<artifactId>ncmc-acquirer-bus-common</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<version>2.6.7</version>
		<scope>test</scope>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
	<dependency>
		<groupId>org.mockito</groupId>
		<artifactId>mockito-all</artifactId>
		<version>1.10.19</version>
		<scope>test</scope>
	</dependency>

	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.13.2</version>
		<scope>test</scope>
	</dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
		<version>1.18.24</version>
	</dependency>

	<!-- ES DEPENDENCY -->
	<dependency>
		<groupId>co.elastic.clients</groupId>
		<artifactId>elasticsearch-java</artifactId>
		<version>8.1.3</version>
	</dependency>

	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<version>2.12.3</version>
	</dependency>

	<dependency>
		<groupId>jakarta.json</groupId>
		<artifactId>jakarta.json-api</artifactId>
		<version>2.0.1</version>
	</dependency>

</dependencies>
```

---

<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:** [July 6, 2022, 5:55pm UTC](https://discuss.elastic.co/t/getting-this-error-java-lang-classnotfoundexception-jakarta-json-jsonexception/306734/2 "2022-07-06T17:55:58Z")

</div>

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