tomcat-embed-core:10.1.0-M16 will make the import javax.servlet.http.HttpServletResponse cannot be resolve - spring-boot

If I put the latest org.apache.tomcat.embed:tomcat-embed-core:10.1.0-M16 dependecy, it will make the import javax.servlet.http.HttpServletResponse cannot be resolve.
Here's my build.gradle,
plugins {
id 'org.springframework.boot' version '2.7.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'war'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.apache.tomcat.embed:tomcat-embed-core:10.1.0-M16'
}
How do I fixed this?
Thank you!

tomcat-embed-core:9.0.63 provided by Spring Boot also contained repackaged classes from javax.servlet-api library, but they are no longer present in 10.1 branch due to migration from javax.servlet to jakarta.servlet. You could manually add this dependency to fix the compilation error:
compileOnly 'javax.servlet:javax.servlet-api:4.0.1'
However, this alone won't fix the issue, as Spring Boot 2.7 is just not internally compatible with Tomcat 10.1 because of its migration from javax.servlet to Jakarta APIs. If you want to try Tomcat 10.1 with Spring Boot, you'd most probably have to wait until Spring Boot 3 comes out. See more info in Spring Boot blog.

Related

kotlin spring boot 3 - cannot resolve spring-boot-gradle-plugin:3.0.0

I'm getting a weird resolution error when trying to upgrade to spring boot 3. I have a kotlin/spring project. The only thing sort of related is this, but it's not the same dependency.
Here's the error:
Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.0.
Here's my dependency declaration:
plugins {
id 'io.spring.dependency-management' version '1.1.0' // latest at this time
id 'org.springframework.boot' version '3.0.0'
id 'org.jetbrains.kotlin.plugin.jpa' version '1.7.10'
id 'org.jetbrains.kotlin.plugin.spring' version '1.7.10'
}
Here's my full output:
What I've tried:
Switching to Java 17
Searching online for the same exact error - no luck so far. (11-29-2022 10AM ET)
Modify the Gradle JVM in the settings

How can I use Spring Cloud OpenFeign with Spring Boot 3.0.0-M4?

I want to use Spring Cloud OpenFeign with Spring Boot 3.0.0-M4 But I could not find the compatible version of Spring Cloud OpenFeign with spring boot 3.0.0-M4.
for using OpenFeign with this version of spring boot what should I do?
The new Spring Boot milestone version 3.0.0-M5 got released end of September.
You can use the corresponding Spring Cloud version 2022.0.0-M5 which includes Spring Cloud Openfeign 4.0.0-M5.
See https://spring.io/blog/2022/10/06/spring-cloud-2022-0-0-m5-is-now-available
(The same most probably works with M4 if you really have to use it)
However I would advise on using https://start.spring.io to generate your project stub and maven or gradle files that take care of selecting the correct versions for Spring Cloud modules like Openfeign.
Shortened example for build.gradle:
plugins {
id 'org.springframework.boot' version '3.0.0-M5'
id 'io.spring.dependency-management' version '1.0.14.RELEASE'
id 'java'
}
sourceCompatibility = '17'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "2022.0.0-M5")
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

getting Spring Boot [2.7.0] is not compatible with this Spring Cloud release train error

I am new to spring.
I was trying to upgrade spring boot version from 2.3.3.RELEASE to 2.6.7 in existing spring batch project.
Project build completed successfully but I am getting bellow error when I run batch. Please help.
***************************
APPLICATION FAILED TO START
***************************
Description:
Your project setup is incompatible with our requirements due to following reasons:
- Spring Boot [2.6.7] is not compatible with this Spring Cloud release train
Action:
Consider applying the following actions:
- Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]
My current code of build.gradle is as below,
buildscript {
ext {
springBootVersion = '2.6.7'
}
}
plugins {
id 'org.springframework.boot' version "${springBootVersion}"
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 11
tasks.named("bootJar") {
archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
mainClass = 'jp.co.BatchApplication'
}
jar.archiveFileName = bootJar.archiveFileName
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-batch:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf:${springBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}")
implementation("org.springframework.retry:spring-retry:1.2.5.RELEASE")
implementation("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.24")
implementation('mysql:mysql-connector-java:8.0.17')
implementation('org.seasar.doma.boot:doma-spring-boot-starter:1.4.0')
annotationProcessor('org.seasar.doma:doma-processor:2.35.0')
implementation('org.apache.commons:commons-lang3:3.11')
implementation('org.apache.commons:commons-collections4:4.4')
implementation('com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.2')
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation(fileTree(dir: 'lib', include: ['*.jar']))
implementation("org.hibernate.validator:hibernate-validator:6.1.5.Final")
implementation('org.apache.httpcomponents:httpclient:4.5.12')
// for r3-id-1.0.1.jar
implementation('commons-digester:commons-digester:2.1')
// Azure App Configuration
implementation('com.microsoft.azure:spring-cloud-azure-appconfiguration-config-web:1.3.0')
implementation('com.microsoft.azure:spring-cloud-azure-feature-management-web:1.3.0')
testImplementation("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
}
*
*
*
*
I guess it is not relevant to this error but I have also change DefaultBatchConfigurer class from use of MapJobRepositoryFactoryBean to JobRepositoryFactoryBean. As MapJobRepositoryFactoryBean is deprecated.
The error is quite explanatory ...
- Spring Boot [2.6.7] is not compatible with this Spring Cloud release train
Spring Cloud versions are tied to specific Spring Boot versions. When using Spring Cloud you cannot just upgrade Spring Boot you also need to upgrade Spring Cloud to a version that supports that Spring Boot version.
As you are using some Azure Cloud dependencies you need to upgrade those to a newer version (if available) that support a Spring Cloud version that supports Spring Boot 2.6.
Pro Tip I would also suggest to cleanup your dependencies so you benefit, more, from the Spring Boot dependency management
dependencies {
implementation("org.springframework.boot:spring-boot-starter-batch")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-aop")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.retry:spring-retry")
implementation("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
implementation('mysql:mysql-connector-java')
implementation('org.seasar.doma.boot:doma-spring-boot-starter:1.4.0')
annotationProcessor('org.seasar.doma:doma-processor:2.35.0')
implementation('org.apache.commons:commons-lang3:3.11')
implementation('org.apache.commons:commons-collections4:4.4')
implementation('com.fasterxml.jackson.dataformat:jackson-dataformat-xml')
implementation("javax.xml.bind:jaxb-api")
// for Mu Client
implementation(fileTree(dir: 'lib', include: ['*.jar']))
implementation('org.apache.httpcomponents:httpclient')
// for r3-id-3.0.1.jar
implementation('commons-digester:commons-digester:2.1')
// Azure App Configuration
implementation('com.microsoft.azure:spring-cloud-azure-appconfiguration-config-web:1.3.0')
implementation('com.microsoft.azure:spring-cloud-azure-feature-management-web:1.3.0')
testImplementation("org.springframework.boot:spring-boot-starter-test")
}

Facing java.lang.NoSuchMethodError and java.lang.NoClassDefFoundError at Visibility.kt:23 when upgrading spring boot from 2.4 to 2.5.x

Facing java.lang.NoSuchMethodError and java.lang.NoClassDefFoundError at Visibility.kt:23 when upgrading spring boot from 2.4 to 2.5.x
Sping Boot - 2.5.0
Java = 10.0.2
Gradle - 7.4.2
kotlin 1.6.21
Project is running fine for Spring boot 2.4.x
Upgrading to 2.5.x throws java.lang.NoSuchMethodError and java.lang.NoClassDefFoundError error.
Tried below options but no luck:
Cleared the gradle cache
Uninstalled and installed intellij ID
buil.gradle:
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Required for Kotlin integration
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
}
}
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'kotlin' // Required for Kotlin integration
apply plugin: "kotlin-spring"
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" // Required for Kotlin integration
implementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
implementation 'org.springframework.boot:spring-boot-starter-parent:2.6.7'
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-jdbc"
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.13.2'
testImplementation "org.springframework.boot:spring-boot-starter-test"
// end::tests[]
}
Let me know if I miss any

Trying to run a cloned project with gradle but unable to build

I have cloned a Spring boot project from github and I have opened it in intellij. So I am trying to run the build.gradle but I just get this error:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.3.3.RELEASE']
Failed to apply plugin [id 'org.springframework.boot']
Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 5.2
This is the plugin:
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
What is going on here?
You have Gradle version 5.2. The error states that the Spring Boot plugin specifically requires either 5.6.x (e.g., 5.6.4) or a version greater than or equal to 6.3 (e.g., 6.3, 6.6.1).
You need to upgrade your Gradle version to a 5.6 variant or a newer version that is greater than or equal to 6.3.
You need to configure a Gradle version for a project to be 5.6.x only or 6.3 or later:
If wrapper.properties is used for the project the Gradle version is saved in the gradle-wrapper.properties file in the gradle directory of your project.
See detailed steps at Configure a Gradle version for a project
documentation page.

Resources