Closed loicgreffier closed 7 months ago
Thanks for the sample application.
Spring Framework 6.1 has raised the Jackson baseline to 2.14. Because you're not using the Spring Boot BOM, your sample is getting Jackson 2.13. This is happening because Maven has a closes wins strategy and you're getting the dependency via kafka-streams
rather than spring-boot-starter-web
-> spring-boot-json
.
You can add the following to fix the Jackson issue:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
<version>${spring-boot.version}</version>
</dependency>
Or even better, I'd look at using our BOM, even if you don't want to use our parent.
@philwebb @loicgreffier could you please help with the below. I am using spring boot starter parent and I just updated my project to 3.2.0 and get the error ClassNotFound com/fasterxml/jackson/databind/cfg/DatatypeFeature. I have added a dependency for jackson-databind(com.fasterxml.jackson.core) version 2.13.4.2 in my pom.xml too. Still I get this error. Could you please suggest what dependency to add to solve this class not found?
As @philwebb said above, Spring Framework 6.1 (and therefore Spring Boot 3.2) requires Jackson 2.14.x or later. 2.13.4.2 is too old and you should upgrade.
thanks a lot @wilkinsona , rather than mentioning jackson core and jackson datatype in pom.xml, I removed these dependencies as they are already added by spring-boot-starter-parent 3.2.0. I get all needed spring 6.1.1 dependencies and jackson 2.15.3 dependencies from the parent automatically. But I get error while running the application No JTA platform available (set hibernate transaction jta platform to enable JTA platform integration) Could you please tell if this error is because of incorrect dependencies?
I'm afraid it's impossible to say without some more information.
If you have any further questions, please follow up on Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
In my case, I encountered an error when creating the Docker image. The exception message is: Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication at org.sintaxy.delivery_api.StartApp.main(StartApp.java:12)
However, it works normally when I create a JAR and run it directly on the machine.
build.gradle
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.0'
// id "com.ewerk.gradle.plugins.querydsl" version "1.1.0"
// id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}
group = 'org.sintaxy'
version = '1.0.0'
java {
sourceCompatibility = '17'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
queryDslVersion = "5.0.0"
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
// gson
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
// https://mvnrepository.com/artifact/net.sf.jtidy/jtidy
implementation group: 'net.sf.jtidy', name: 'jtidy', version: 'r938'
implementation group: 'io.hypersistence', name: 'hypersistence-utils-hibernate-60', version: '3.3.2'
// jakarta
implementation 'jakarta.validation:jakarta.validation-api:3.0.0'
// barcode
implementation group: 'com.google.zxing', name: 'core', version: '3.5.2'
// https://mvnrepository.com/artifact/com.google.zxing/javase
implementation group: 'com.google.zxing', name: 'javase', version: '3.5.2'
// security
implementation 'org.springframework.security:spring-security-oauth2-resource-server:6.1.1'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:3.1.2'
// keycloak
implementation 'org.keycloak:keycloak-admin-client:15.0.2'
// https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf
implementation group: 'org.xhtmlrenderer', name: 'flying-saucer-pdf', version: '9.1.22'
// email
implementation 'org.springframework.boot:spring-boot-starter-mail'
// Swagger
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.3.0'
implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.amqp:spring-rabbit-test'
testImplementation 'org.springframework.security:spring-security-test'
// QueryDSL
implementation("com.querydsl:querydsl-core:${queryDslVersion}")
implementation("com.querydsl:querydsl-jpa:${queryDslVersion}:jakarta")
annotationProcessor(
"com.querydsl:querydsl-apt:${queryDslVersion}:jakarta",
"jakarta.persistence:jakarta.persistence-api:3.1.0",
)
}
tasks.named('test') {
useJUnitPlatform()
}
if (project.hasProperty('jarName')) {
ext.jarName = project.property('jarName')
} else {
ext.jarName = rootProject.name
}
jar {
archiveFileName = "${jarName}.jar"
manifest {
attributes 'Main-Class': 'org.sintaxy.delivery_api.StartApp'
}
}
@antonio031 I don't see the connection between the error you're seeing and a Jackson class being absent. It sounds like your Docker image has created the classpath incorrectly which means that the spring-boot
jar isn't on the classpath. If you need some help correcting your Dockerfile, please ask a question on Stack Overflow.
I have upgraded spring boot parent version to 3.2.2 and also as u mentioned in above comments i have added this dependency and still im getting same error
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.cfg.DatatypeFeature
@Pankajomkar check the version of Jackson on your application's classpath. It sounds like it's too old.
I solved this by changing all the otel related version to 1.31.0
After upgrading to Spring Boot 3.2.0, my build fails with the following error:
A code sample to reproduce is available here: https://github.com/loicgreffier/datatype-feature-spring-boot
I am not using the Spring Boot parent. There is no issue on Spring Boot 3.1.6