• 解决Sentinel module java.base does not “opens java.lang“ to unnamed module问题


    1 环境

    • Sentinel 1.8.3
    • OpenJDK 17.0.2
    • Manjaro

    2 问题描述

    根据官方Github Wiki使用如下命令启动Sentinel

    java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
    

    报错截图如下:

    在这里插入图片描述

    摘要如下:

    java.lang.IllegalStateException: Cannot load configuration class: com.alibaba.csp.sentinel.dashboard.DashboardApplication
    Caused by: org.springframework.cglib.core.CodeGenerationException: 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 @74fdb593
    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 @74fdb593
    

    可以看到异常来自于InaccessibleObjectException,报错信息为module java.base does not "opens java.lang" to unnamed module @74fdb593

    3 问题解决

    其实笔者之前写过一篇文章是关于解决JDK9非法反射访问警告的,这种问题不会在JDK8出现,也是模块化的问题,因此解决方式类似,开放模块即可。

    需要添加如下两个启动参数:

    • --add-opens java.base/java.lang=ALL-UNNAMED
    • --add-opens java.base/sun.net.util=ALL-UNNAMED

    即可,完整命令如下:

    java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.net.util=ALL-UNNAMED -jar sentinel-dashboard-1.8.3.jar
    

    更换一下端口以及Sentinel版本即可。

  • 相关阅读:
    boost::VS2017下编译和配置boost库
    cmake::编译一个工程
    cmake::helloworld
    python模块之urllib
    Python报错:UnicodeEncodeError 'gbk' codec can't encode character
    word页眉添加横线与删除横线
    练习五十九:字典排序
    练习五十八:列表的练习
    练习五十七:for循环 809??=800*?+9*?+1其中?代表的两位数,8*?的结果为两位数,9*?的结果为3位数。求?代表的两位数,及809??后的结果
    windows查看网络常用cmd命令
  • 原文地址:https://www.cnblogs.com/6b7b5fc3/p/16005861.html
Copyright © 2020-2023  润新知