Comments (9)
Solved it by adding
implementation("jakarta.json:jakarta.json-api:2.0.1")
from elasticsearch-java.
Getting this error java.lang.ClassNotFoundException: jakarta.json.JsonException
tags changed: → language-clients
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:
<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>
@swallez @adriancosma88 @leorosignoli can you help here
from elasticsearch-java.
Are you sure you didn't have to do anything else? I'm facing this same problem and adding this dependency didn't solve my case.
from elasticsearch-java.
We've added some documentation on this issue related to Spring's Gradle and Maven plugins https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/installation.html
from elasticsearch-java.
I am also experiencing this issue. I am using the following dependencies:
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.1.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
<version>2.0.0</version>
</dependency>
from elasticsearch-java.
Are you sure you didn't have to do anything else? I'm facing this same problem and adding this dependency didn't solve my case.
Yeah, I don't remember having to change anything else. This is my current build.gradle.kts:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.7.0-SNAPSHOT"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("org.flywaydb.flyway") version "8.2.0"
kotlin("jvm") version "1.6.0"
kotlin("plugin.spring") version "1.6.0"
}
group = "com.codinghumans"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
maven { url = uri("https://repo.spring.io/milestone") }
maven { url = uri("https://repo.spring.io/snapshot") }
}
dependencies {
// Spring boot dependencies
developmentOnly("org.springframework.boot:spring-boot-devtools")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-security")
// Elasticsearch dependencies
implementation("co.elastic.clients:elasticsearch-java:7.16.2")
implementation("com.fasterxml.jackson.core:jackson-databind:2.12.3")
implementation("jakarta.json:jakarta.json-api:2.0.1")
// Mysql dependencies
implementation("mysql:mysql-connector-java:8.0.27")
// Flyway dependencies
implementation("org.flywaydb:flyway-core:8.3.0")
implementation("org.flywaydb:flyway-mysql:8.3.0")
// AWS dependencies
implementation("org.springframework.cloud:spring-cloud-aws-messaging:2.2.6.RELEASE")
implementation("com.amazonaws:aws-java-sdk-sqs:1.12.131")
implementation("com.ibm.icu:icu4j:70.1")
// Kotlin dependencies
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
// Test dependencies
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
If you're using kotlin make sure you have:
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
from elasticsearch-java.
@adriancosma88 adding the following dependency should solve the issue:
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.1</version>
</dependency>
from elasticsearch-java.
<dependency>
<groupId>org.opensearch.client</groupId>
<artifactId>opensearch-java</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
<version>2.20.54</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.1</version><!--$NO-MVN-MAN-VER$-->
</dependency>
from elasticsearch-java.
I don't understand. Why gradle or maven does not download dependency. For example, normally you put an item in pom or gradle.build, it should download all dependencies that item requires.
from elasticsearch-java.
Related Issues (20)
- On the issue of termvectors queries
- Regarding termvectors query related issues HOT 1
- PutSynonymResponse: Failed to decode response HOT 2
- TermsBucketBase: doc_count_error should be doc_count_error_upper_bound HOT 1
- Read By Id: Failed to decode response
- Assign a tokenizer to a field when creating an index. 8.6.0 HOT 1
- co.elastic.clients.elasticsearch.ElasticsearchClient.delete responce nullpointerexception HOT 2
- Creating aggregation from json via supplied reader HOT 1
- Building a zero result response declares missing properties as mandatory which should be optional HOT 1
- `field_masking_span` is deprecated in ES8.0+ but still used in java client HOT 4
- Cannot parse DynamicTemplate mapping with unknown field HOT 5
- Encountering NoSuchMethodError when Creating Elasticsearch Client
- PutTemplateRequest - `Unknown field 'composed_of'` HOT 1
- Snowball token filter with default language breaks `indices.get()` HOT 1
- I can't disable the 'type#name' format in the deserialization of the response HOT 1
- New lightweight http layer based on JDK 11
- New http layer based on Apache HTTP 5.x
- Support for geo distance sort on nested fields HOT 2
- JsonpMappingException thrown when parsing explicitly null co.elastic.clients.elasticsearch._types.Script from Json HOT 1
- Deserilizing error calling the healthReport() method.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-java.