关于解决module java.base does not “opens java.lang” to unnamed module @333291e3的办法
1.抛出异常
在使用Dubbo和Zookeeper做一个分布式项目时,抛出以下异常:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-07-20 17:00:42.979 ERROR 6920 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ServiceBean:com.bjpowernode.api.service.PlatBaseInfoService:1.0':
Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
以下是抛出异常的导致因素:
Caused by: java.lang.ExceptionInInitializerError: null
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
Caused by: java.lang.IllegalStateException: Failed to create adaptive instance: java.lang.IllegalStateException: Can't create adaptive extension interface
org.apache.dubbo.rpc.Protocol, cause: 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 @333291e3
at org.apache.dubbo.common.extension.ExtensionLoader.getAdaptiveExtension(ExtensionLoader.java:486) ~[dubbo-2.7.3.jar:2.7.3]
at org.apache.dubbo.config.ServiceConfig.<clinit>(ServiceConfig.java:119) ~[dubbo-2.7.3.jar:2.7.3]
... 24 common frames omitted
还有2个Caused by,就不列举了。
2.异常原因
3.解决办法
方案二:如果使用JDK17,可以在vm options 增加以下运行参数 。
–add–opens java.base/java.lang=ALL-UNNAMED —add–opens java.base/java.lang.reflect=ALL-UNNAMED
在vm options选项中填入:
–add–opens java.base/java.lang=ALL-UNNAMED —add-opens java.base/java.lang.reflect=ALL-UNNAMED
本人尝试过了,这种方法会抛出新的异常,待解决。(可能是vm options的参数不对)
原文地址:https://blog.csdn.net/ilikeavr/article/details/131835031
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_23536.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。