• 解决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版本即可。

  • 相关阅读:
    零散的小知识0
    windows 安装touch指令
    sba
    jQuery中mouseenter vs mouseover 以及 mouseleave vs mouseout
    SSAS: Pareto Analysis
    SSAS: Display measures in Rows
    SSAS: Using DMV Queries to get Cube Metadata
    Do not execute sub-report when it's hidden in SSRS
    Read data from Excel XML file
    Concatenating Row Values in Transact-SQL
  • 原文地址:https://www.cnblogs.com/6b7b5fc3/p/16005861.html
Copyright © 2020-2023  润新知