I am getting this exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 and java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
) when i run the spring boot application
I am using below tools
STS 3.9.10 release
Open JDK 14 64 bit
Spring boot 2.2.5
It worked fine with oracle jdk but its failing to run with openjdk. I am not using any groovy libs. This is maven based spring boot project.
How do you run the application? It's probably because you use Gradle as the build system and JDK14 and the Gradle version is old. Reference: https://github.com/gradle/gradle/issues/10248
If you use Gradle Wrapper then refer to $PROJECT_ROOT/gradle/wrapper/gradle-wrapper.properties
. The property distributionUrl
should be:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
If it's an older version then change it, run ./gradlew clean build
and try again.
I solved it by editing the gradle-wrapper.properties file inside the gradle folder. (Not .gradle) :
Change this line, from:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
to:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
rebuild and it's ok.
In the file android/gradle/wrapper/gradle-wrapper.properties
, ensure that the distributionUrl
is as follows:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
Note: If you installed jdk 14
Got the same issue on a Maven & SpringBoot project, no Gradle whatever.
The dependency to org.codehaus.groovy is probably transitive through spring-cloud-contract-verifier. Run mvn dependency:tree
to view the whole dependency tree.
I got it fixed by upgrading the spring-cloud-contract-maven-plugin version to 2.2.3-RELEASE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With