Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.C

这篇具有很好参考价值的文章主要介绍了Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.C。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

最近在学习JDK17的时候遇到这么一个问题,springBoot启动失败,日志如下:

Exception in thread "main" java.lang.IllegalArgumentException: Unable to instantiate factory class [com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer] for factory type [org.springframework.context.ApplicationContextInitializer]
	at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$throwing$0(SpringFactoriesLoader.java:650)
	at org.springframework.core.io.support.SpringFactoriesLoader$FailureHandler.lambda$handleMessage$3(SpringFactoriesLoader.java:674)
	at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:231)
	at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:206)
	at org.springframework.core.io.support.SpringFactoriesLoader.load(SpringFactoriesLoader.java:160)
	at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:459)
	at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:455)
	at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:273)
	at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:252)
	at com.zzz.train.business.BusinessApplication.main(BusinessApplication.java:20)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.springframework.core.io.support.SpringFactoriesLoader$FactoryInstantiator.instantiate(SpringFactoriesLoader.java:381)
	at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:228)
	... 7 more
Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to load instance for com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory!
	at com.ctrip.framework.apollo.spring.util.SpringInjector.getInstance(SpringInjector.java:40)
	at com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer.<init>(ApolloApplicationContextInitializer.java:48)
	... 14 more
Caused by: com.ctrip.framework.apollo.exceptions.ApolloConfigException: Unable to initialize Apollo Spring Injector!
	at com.ctrip.framework.apollo.spring.util.SpringInjector.getInjector(SpringInjector.java:24)
	at com.ctrip.framework.apollo.spring.util.SpringInjector.getInstance(SpringInjector.java:37)
	... 15 more
Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.ExceptionInInitializerError
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830)
	at com.google.inject.internal.FailableCache.get(FailableCache.java:48)
	at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
	at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:138)
	at com.google.inject.internal.InjectorImpl.initializeBinding(InjectorImpl.java:536)
	at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run(AbstractBindingProcessor.java:160)
	at com.google.inject.internal.ProcessedBindingData.initializeBindings(ProcessedBindingData.java:44)
	at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:123)
	at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
	at com.google.inject.Guice.createInjector(Guice.java:99)
	at com.google.inject.Guice.createInjector(Guice.java:73)
	at com.google.inject.Guice.createInjector(Guice.java:62)
	at com.ctrip.framework.apollo.spring.util.SpringInjector.getInjector(SpringInjector.java:22)
	... 16 more
Caused by: java.lang.ExceptionInInitializerError
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.getProtectionDomain(FastClass.java:73)
	at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create(AbstractClassGenerator.java:206)
	at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create(FastClass.java:65)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:252)
	at com.google.inject.internal.BytecodeGen.newFastClassForMember(BytecodeGen.java:203)
	at com.google.inject.internal.DefaultConstructionProxyFactory.create(DefaultConstructionProxyFactory.java:53)
	at com.google.inject.internal.ProxyFactory.create(ProxyFactory.java:158)
	at com.google.inject.internal.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:90)
	at com.google.inject.internal.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
	at com.google.inject.internal.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
	at com.google.inject.internal.FailableCache$1.load(FailableCache.java:37)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
	... 32 more
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 @d35dea7
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at com.google.inject.internal.cglib.core.$ReflectUtils$1.run(ReflectUtils.java:52)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at com.google.inject.internal.cglib.core.$ReflectUtils.<clinit>(ReflectUtils.java:42)
	... 48 more

Process finished with exit code 1

原因:这是由于 JDK 8 中有关反射相关的功能自从 JDK 9 开始就已经被限制了,为了兼容原先的版本,需要在运行项目时添加 --add-opens java.base/java.lang=ALL-UNNAMED 选项来开启这种默认不被允许的行为。

解决方案:

caused by: java.lang.reflect.inaccessibleobjectexception: unable to make pro,java

结果:

caused by: java.lang.reflect.inaccessibleobjectexception: unable to make pro,java文章来源地址https://www.toymoban.com/news/detail-772642.html

到了这里,关于Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.C的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • java.lang.reflect.InaccessibleObjectException

    低版本springboot应用使用高版本JDK报以下异常: 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 un

    2024年04月28日
    浏览(17)
  • 关于java.lang.reflect.InaccessibleObjectException异常

    在使用javassist插件的时候,jdk版本大于8的时候没有对应的包会导致出现以下异常 java.lang.reflect.InaccessibleObjectException   点击后选择Edit Configurations...  修改如下信息即可 --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.net.util=ALL-UNNAMED  修改后记得将构造选择为对应的内容

    2024年02月13日
    浏览(18)
  • jdk 8以上版本报错 :Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect...

    具体报错信息: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not \\\"opens java.lang.reflect\\\" to unnamed module @7674f035 需要设置启动参数 --add-opens java.base/java.lang.reflect=ALL-UNNAMED

    2024年02月20日
    浏览(50)
  • 解决Caused by: java.lang.IllegalStateException:

    目录 问题描述 解决方案 1. 修改JVM的-Xss参数 2. 检查循环继承依赖项 3. 更新相关库和依赖 总结 在使用Java开发Web应用程序时,我们有时会遇到​ ​Caused by: java.lang.IllegalStateException​ ​​异常,其中包含一个关于StackOverflow错误的描述。这种错误可能会导致无法完成对Web应用程

    2024年02月03日
    浏览(28)
  • 出现Caused by: java.lang.NullPointerException异常的解决方法

    拿到老师的项目,项目启动时正常,网页提交数据时出现Caused by: 报错, 上一条日志显示 是连接mysql的时候出现bug导致的, 查了一下是数据库版本不匹配问题, 于是我看了一下自己电脑的mysql版本 哇哦,是mysql8.0,再看一下依赖里的mysql版本 是mysql5.1.32,这俩版本不匹配,

    2024年02月11日
    浏览(66)
  • Caused by: java.lang.IllegalStateException: No DataSource set

    如果Nacos连不上数据库,还哪都配置正确,请注意时区 serverTimezone=Asia/Shanghai

    2024年02月11日
    浏览(42)
  • Tomcat Caused by: java.lang.ClassNotFoundException: java.util.logging.Logger

    本质原因:JRE_HOME的环境变量配置不正确 进入jdk文件夹 windows下执行: binjlink.exe --module-path jmods --add-modules java.desktop --output jre linux下执行: bin/jlink --module-path jmods --add-modules java.desktop --output jre JRE_HOME: java8 需要加上jre目录,java 11 只需要与JAVA_HOME保持一致即可

    2024年02月16日
    浏览(20)
  • Caused by: java.lang.IllegalStateException: Failed to introspect Class

    1、问题报错如下: 2、问题解析: 意思是:未能反射rabbitmq类包(就是添加了依赖没加载进去);需与ClassNotFindException的错误区分,此异常是引用了没有依赖的类。 3、解决方案: 方案一(如果导入的依赖“scope”标签为值provided,则修改如下): 改为如下所示:(去掉scop

    2024年02月11日
    浏览(19)
  • 解决Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘inteController‘

    出现这个错也可能会出现项目无法启动的错误。完整错误是 一、错误出现原因 :         controller层出现了重复的方法映射                  可以看到图片中两个方法的映射是一样的,这是问题所在 解决方法也很简单,既然已经知道了问题所在那么解决起来也很简单

    2024年02月10日
    浏览(15)
  • Caused by: java.lang.IllegalStateException: failed to obtain node locks, tri

    我的情况是生产环境中,elasticsearch突然崩溃,然后起不来了。 我的日志目录在 日志信息为 Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/data/elk_data/my-elk-cluster]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_sto

    2024年02月12日
    浏览(21)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包