英文:
Getting NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
问题
我启动Spring Boot应用程序时遇到以下错误。
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]
经过大量搜索,我发现了多个类似的实例,包括 https://stackoverflow.com/questions/61289461/java-lang-noclassdeffounderror-could-not-initialize-class-org-codehaus-groovy-v,但大多数是关于较旧版本的gradle和groovy的旧帖子,或者与Android有关。
这是我的版本信息:
$ 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
我除了在完全使用Groovy/Spock的单元测试中没有使用任何Groovy外,我还在使用gradle作为我的构建引擎。
根据我找到的指示,我已经将我的 gradle-wrapper.properties
文件更改为:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
之前是 6.5-bin
。
这个项目在我的旧计算机上使用Java 8正常运行。我将其移动到新的工作站,并尝试切换到 open JDK 14
,然后出现了这个新问题。
不知道从哪里开始解决。
英文:
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 https://stackoverflow.com/questions/61289461/java-lang-noclassdeffounderror-could-not-initialize-class-org-codehaus-groovy-v, 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.
答案1
得分: 5
从https://github.com/gradle/gradle/issues/10248
看起来 GROOVY-9211 不会被反向移植到2.5.x版本。所以似乎 Gradle 在支持JDK 14之前需要升级到Groovy 3.x版本。
在Gradle使用Groovy 3.x之前,您需要使用JDK 13。
英文:
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.
答案2
得分: 0
我在使用Maven 3.2和JDK 1.8时遇到了相同的问题。升级到JDK 11后问题解决了。
英文:
I had the same issue using maven 3.2. and JDK 1.8. Upgrading to JDK 11 solved it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论