alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.16k stars 7.95k forks source link

Dashboard can not start: java.lang.reflect.InaccessibleObjectException | 控制台本地启动不了 #2439

Open urizenk opened 2 years ago

urizenk commented 2 years ago

为什么本地启动不了,它总是报反射错误,但是我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 unnamed module @3a82ac97

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 @3a82ac97

java.lang.IllegalStateException: Cannot load configuration class: com.alibaba.csp.sentinel.dashboard.DashboardApplication

jdk版本1.8

sczyh30 commented 2 years ago

java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @3a82ac97

这个看起来是 JDK 9+ 的版本,可否提供下具体版本

urizenk commented 2 years ago

sentinel-dashboard-1.8.2.jar sentinel-dashboard-1.7.1.jar sentinel-dashboard-1.7.0.jar 这三个版本的,我看官网说了只要Java6以上就行,不太想改根目录的jdk版本,会有冲突

jiang13021 commented 2 years ago

感觉像是JDK 9+的问题,我用JDK 17的时候遇到了类似的问题。试试增加VM选项

--add-opens java.base/java.lang=ALL-UNNAMED

看看还报不报错。 StackOverflow上有相关的讨论 https://stackoverflow.com/questions/41265266/how-to-solve-inaccessibleobjectexception-unable-to-make-member-accessible-m

Reagan1947 commented 2 years ago

感觉像是JDK 9+的问题,我用JDK 17的时候遇到了类似的问题。试试增加VM选项

--add-opens java.base/java.lang=ALL-UNNAMED

看看还报不报错。 StackOverflow上有相关的讨论 https://stackoverflow.com/questions/41265266/how-to-solve-inaccessibleobjectexception-unable-to-make-member-accessible-m

It do solve my Dashboard problem ! 👍

For More Detail below :

 java -Dserver.port=9000  --add-opens java.base/java.lang=ALL-UNNAMED -jar sentinel-dashboard-1.8.2.jar
AmosWang0626 commented 2 years ago

感觉像是JDK 9+的问题,我用JDK 17的时候遇到了类似的问题。试试增加VM选项

--add-opens java.base/java.lang=ALL-UNNAMED

看看还报不报错。 StackOverflow上有相关的讨论 https://stackoverflow.com/questions/41265266/how-to-solve-inaccessibleobjectexception-unable-to-make-member-accessible-m

It do solve my Dashboard problem ! 👍

For More Detail below :

  • My JDK Version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)
OpenJDK 64-Bit Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode, sharing)
  • My command Line
 java -Dserver.port=9000  --add-opens java.base/java.lang=ALL-UNNAMED -jar sentinel-dashboard-1.8.2.jar

亲测OK

baymax55 commented 2 years ago

it works for me

miozus commented 2 years ago

answers above not works.

❯ java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment Corretto-8.312.07.1 (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM Corretto-8.312.07.1 (build 25.312-b07, mixed mode)
miozus ~

but switch JDK 17 -> 8 works for me

❯ java -jar "E:\Java\sentinel\sentinel-dashboard-1.8.0.jar" --server.port=8333
INFO: Sentinel log output type is: file
INFO: Sentinel log charset is: utf-8
INFO: Sentinel log base directory is: C:\Users\miozus\logs\csp\
INFO: Sentinel log name use pid is: false
...(success)