英文:
java.lang.ClassNotFoundException: org.grails.core.cfg.DeprecatedGrailsConfig
问题
我正在将一个 Grails 3.3.16 应用程序升级到 Grails 5.3.2。当我运行 grails run-app 时,我遇到了一个奇怪的异常,但在我的代码中找不到源,也找不到在线解决方案。
希望有人遇到类似的问题并能为这个错误的源提供一些线索。
更新:我认为这里存在一个双重问题:1. 看起来我正在使用的某个配置已经被弃用,2. 当 Grails 报告弃用时,它使用了在 Grails 5 中不存在的类,因此我得到了这个错误而不是我需要更改的配置错误。也许其他人可以提供更好的诊断。如果是这样,除了我的配置错误之外,Grails 5 中还存在一个 bug。
org.springframework.beans.factory.BeanCreationException: 创建名为 'convertersConfigurationInitializer' 的 Bean 时出错:查找方法解析失败;嵌套异常是 java.lang.IllegalStateException: 从类加载器 [jdk.internal.loader.ClassLoaders$AppClassLoader@67424e82] 内部检查类 [org.grails.web.converters.configuration.ConvertersConfigurationInitializer] 失败
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
...
(更多异常信息省略)
Caused by: java.lang.IllegalStateException: 从类加载器 [jdk.internal.loader.ClassLoaders$AppClassLoader@67424e82] 内部检查类 [org.grails.web.converters.configuration.ConvertersConfigurationInitializer] 失败
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)
...
(更多异常信息省略)
Caused by: java.lang.NoClassDefFoundError: org/grails/core/cfg/DeprecatedGrailsConfig
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)
...
(更多异常信息省略)
Caused by: java.lang.ClassNotFoundException: org.grails.core.cfg.DeprecatedGrailsConfig
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
...
(更多异常信息省略)
英文:
I'm updating a Grails 3.3.16 app to Grails 5.3.2. When I grails run-app I'm getting a strange exception and can't see the source is in my code, and couldn't find a solution online.
Hope someone had a similar issue and can give some light to the source on this error.
UPDATE: I think there is a double issue here: 1. it seems one config I'm using is deprecated, 2. when Grails reports the deprecation, it uses a class that doesn't exists in Grails 5, so I get that error and not the error of the config I need to change. Maybe others can have a better diagnosis. If it's that, there is a bug in Grails 5 besides my config bug.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'convertersConfigurationInitializer': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.grails.web.converters.configuration.ConvertersConfigurationInitializer] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@67424e82]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
at grails.boot.GrailsApp.run(GrailsApp.groovy:485)
at grails.boot.GrailsApp.run(GrailsApp.groovy:472)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at openehr.opt.gui.Application.main(Application.groovy:8)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.grails.web.converters.configuration.ConvertersConfigurationInitializer] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@67424e82]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)
... 28 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/grails/core/cfg/DeprecatedGrailsConfig
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)
... 30 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.grails.core.cfg.DeprecatedGrailsConfig
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 34 common frames omitted
答案1
得分: 1
我遇到了同样的问题,基本上是因为我的一个依赖项添加了:
+--- org.grails:grails-datastore-rest-client:5.0.1.RELEASE
| +--- org.codehaus.groovy:groovy:2.4.5 -> 2.5.14
| +--- commons-codec:commons-codec:1.5 -> 1.13
| +--- org.grails:grails-plugin-converters:3.0.12
这导致了问题。你可以运行 gradlew dependencies
命令查看所有的依赖项以及它们的来源,肯定 3.0.12 版本与 Grails 4 或 5 不兼容。
当我移除了那个依赖项后,converters 版本升级到了 4.0.1,并且项目开始正常运行。
英文:
I had the same issue, basically one of my dependencies was adding:
+--- org.grails:grails-datastore-rest-client:5.0.1.RELEASE
| +--- org.codehaus.groovy:groovy:2.4.5 -> 2.5.14
| +--- commons-codec:commons-codec:1.5 -> 1.13
| +--- org.grails:grails-plugin-converters:3.0.12
which caused the issue. You can call gradlew dependencies
to see all your dependencies and where they come from Definitely 3.0.12 is not compatible with Grails 4 or 5
When I removed that dependency converters version bumped to 4.0.1 and project started
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论