简体   繁体   中英

Getting NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

I am getting the following error when I start my Spring Boot application.

java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
    at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33) ~[groovy-2.5.8.jar:2.5.8]
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) ~[na:na]
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.createMetaMethodFromClass(MetaClassRegistryImpl.java:258) ~[groovy-2.5.8.jar:2.5.8]
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:111) ~[groovy-2.5.8.jar:2.5.8]
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:86) ~[groovy-2.5.8.jar:2.5.8]
    at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36) ~[groovy-2.5.8.jar:2.5.8]
    at org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.<init>(GroovyBeanDefinitionReader.java:150) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.boot.BeanDefinitionLoader.<init>(BeanDefinitionLoader.java:85) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.createBeanDefinitionLoader(SpringApplication.java:738) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:681) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:392) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at pizzainthecloud.pizzaplace.Application.main(Application.java:23) ~[main/:na]

After much searching, I found several instances of this including java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 , but most are older posts on older versions of gradle and groovy or they are related to android.

Here is my version info:

$ gradle -version

------------------------------------------------------------
Gradle 6.6.1
------------------------------------------------------------

Build time:   2020-08-25 16:29:12 UTC
Revision:     f2d1fb54a951d8b11d25748e4711bec8d128d7e3

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          14.0.2 (Oracle Corporation 14.0.2+12-46)
OS:           Linux 5.4.0-42-generic amd64

I am not doing any groovy apart from my unit tests that are entirely groovy/spock and I'm using gradle for my build engine.

Following directions I found, I went ahead and changed my gradle-wrapper.properties file to

distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip

it was 6.5-bin.

This project was running fine on my old computer with Java 8. I moved it to my new workstation and am trying to move to open JDK 14 , and that is when the new issue started.

Wondering where to go from here.

From https://github.com/gradle/gradle/issues/10248

Seems like GROOVY-9211 won't be backported to 2.5.x. So it seems that Gradle will need to upgrade to Groovy 3.x once it's out in order to support JDK 14.

You will need to use JDK 13 until Gradle uses Groovy 3.x.

I had the same issue using maven 3.2. and JDK 1.8. Upgrading to JDK 11 solved it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM