Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example-nacos启动时报错 #440

Open
wzk9261 opened this issue Jul 12, 2024 · 0 comments
Open

example-nacos启动时报错 #440

wzk9261 opened this issue Jul 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@wzk9261
Copy link

wzk9261 commented Jul 12, 2024

首先感谢您使用 DynamicTp,如果使用过程中有任何问题,请按照下述模板反馈问题,建议使用 Markdown 语法

版本信息

  • Jdk版本:17
  • SpringBoot版本:3.1.4
  • DynamicTp版本:1.1.7-3.x
  • 配置中心版本:Nacos 2.3.1
  • 分支:springboot3

问题描述

example-nacos启动时报错:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @3a52dba3
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) ~[na:na]
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) ~[na:na]
at net.sf.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61) ~[cglib-3.3.0.jar:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) ~[na:na]
at net.sf.cglib.core.ReflectUtils.(ReflectUtils.java:52) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332) ~[cglib-3.3.0.jar:na]
... 63 common frames omitted
然后自己搜了一下解决方案,给SpringApplication加了VM option:--add-opens java.base/java.lang=ALL-UNNAMED,再次启动报另一个错误:
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 61
at org.objectweb.asm.ClassReader.(ClassReader.java:195) ~[asm-7.1.jar:7.1]
at org.objectweb.asm.ClassReader.(ClassReader.java:176) ~[asm-7.1.jar:7.1]
at org.objectweb.asm.ClassReader.(ClassReader.java:162) ~[asm-7.1.jar:7.1]
at org.objectweb.asm.ClassReader.(ClassReader.java:283) ~[asm-7.1.jar:7.1]
at net.sf.cglib.core.DuplicatesPredicate.(DuplicatesPredicate.java:93) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.proxy.Enhancer.getMethods(Enhancer.java:557) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:575) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[cglib-3.3.0.jar:na]
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:na]
at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480) ~[cglib-3.3.0.jar:na]
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:324) ~[cglib-3.3.0.jar:na]
at org.dromara.dynamictp.common.plugin.DtpInterceptorProxyFactory.enhance(DtpInterceptorProxyFactory.java:52) ~[classes/:na]
at org.dromara.dynamictp.common.plugin.DtpInterceptor.plugin(DtpInterceptor.java:54) ~[classes/:na]
at org.dromara.dynamictp.common.plugin.DtpInterceptorRegistry.plugin(DtpInterceptorRegistry.java:94) ~[classes/:na]
at org.dromara.dynamictp.core.spring.DtpPostProcessor.registerAndReturnDtp(DtpPostProcessor.java:106) ~[classes/:na]
at org.dromara.dynamictp.core.spring.DtpPostProcessor.postProcessAfterInitialization(DtpPostProcessor.java:94) ~[classes/:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434) ~[spring-beans-6.0.12.jar:6.0.12]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1773) ~[spring-beans-6.0.12.jar:6.0.12]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.12.jar:6.0.12]
... 42 common frames omitted

  • 猜测可能原因:项目的CGLIB版本为3.3.0,太低了,确实可能与JDK 17存在兼容性问题,尤其是在处理更高版本的字节码方面。CGLIB使用ASM库来生成字节码,而ASM库需要更新以支持更高版本的Java类文件格式。当CGLIB使用一个过时的ASM版本时,它可能无法正确地解析或生成由JDK 17编译的类文件,因为这些类文件采用了Java 17特有的字节码版本(即版本61)。另外,切到分支master(对应spring-boot 2.7.x)就没有这个问题,可能更验证了这个猜想。
@wzk9261 wzk9261 added the bug Something isn't working label Jul 12, 2024
@wzk9261 wzk9261 changed the title bug example-nacos启动时报错 Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant