'Facing NoSuchMethodError and NoClassDefFoundError after Spring boot upgrade from 2.4.x to 2.5.x
Error logged while running gradle clean build:
java.lang.Exception: Unexpected exception, expected<org.springframework.web.client.HttpClientErrorException> but was<java.lang.NoSuchMethodError>
at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:30)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
Caused by: java.lang.NoSuchMethodError: kotlin.collections.MapsKt.createMapBuilder()Ljava/util/Map; at kotlin.reflect.jvm.internal.impl.descriptors.Visibilities.(Visibilities.kt:56) at kotlin.reflect.jvm.internal.impl.descriptors.Visibility.compareTo(Visibility.kt:23) at kotlin.reflect.jvm.internal.impl.descriptors.DescriptorVisibility.compareTo(DescriptorVisibility.kt:66)
build.gradle
buildscript {
ext.kotlin_version = '1.6.21' // Required for Kotlin integration
ext.spring_boot_version = '2.6.6'
repositories {
mavenCentral()
}
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" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin
apply plugin: "jacoco"
repositories {
mavenCentral()
}
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"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation 'com.github.tomakehurst:wiremock-standalone:2.27.2'
testImplementation 'info.cukes:cucumber-spring:1.2.6'
testImplementation 'info.cukes:cucumber-junit:1.2.6'
implementation 'com.google.code.gson:gson:2.9.0'
// end::tests[]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|