Closed marcmarcet closed 2 years ago
Solved it by adding
implementation("jakarta.json:jakarta.json-api:2.0.1")
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.
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")
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>
@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>
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
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
<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>
Hello, I'm trying to use the elasticsearch-java client in a new kotlin spring boot 2.7.0-SNAPSHOT project. As soon as I add the import for JacksonJsonpMapper() I get the following error:
I'm quite new to java, so I'm a bit lost...Any idea what I might be doing wrong?