Thanks, Matt

it seems that it is the only way to solve this then...

i added an environment variable named "_JAVA_OPTIONS", (which may be a bad 
practice)
and gave its value "--add-opens=java.base/java.lang=ALL-UNNAMED"
after then, apps started successfully.

i also noticed that shell executables in bin folder may need more privileges to 
access old apis.
i added "--add-exports=java.base/sun.net.util=ALL-UNNAMED" for flink-console.sh.

Best regards,
Bill


发件人: Matt Wang <wang...@163.com>
发送时间: 2023年8月29日 20:16
收件人: Xu Bill <xuzhili1...@hotmail.com>
主题: Re:InaccessibleObjectException issue 
 
Hi Bill
For version 1.17.1, you can use JDK11 to submit jobs[1], and JDK17
support starts from 1.18.0[2]. If you want to run with JDK17 now, 
you need to add some JDK configuration[3]

1. 
https://nightlies.apache.org/flink/flink-docs-stable/docs/try-flink/local_installation/#downloading-flink
 
2. https://issues.apache.org/jira/browse/FLINK-15736 
3. 
https://stackoverflow.com/questions/68117860/eclipse-2021-06-classformaterror-accessible-module-java-base-does-not-opens-j
 


--
Best,
Matt Wang

---- Replied Message ---- 
From 
Xu Bill<xuzhili1...@hotmail.com> 
Date 
08/29/2023 17:49 
To 
u...@flink.apache.org<u...@flink.apache.org> 
Subject 
InaccessibleObjectException issue 
Hello,

I'm new to Apache Flink.
I followed the instrunctions to run examples after installation
(as described here: 
https://nightlies.apache.org/flink/flink-docs-stable/docs/try-flink/local_installation/#submitting-a-flink-job)
and also tried running an example java app
(as described here: 
https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/learn-flink/datastream_api/)

But both of them failed to start and gave me same error as below:

Exception in thread "main" java.lang.reflect.InaccessibleObjectException: 
Unable to make field private final byte[] java.lang.String.value accessible: 
module java.base does not "opens java.lang" to unnamed module @4ac3c60d
at 
java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at 
java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:106)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:132)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:132)
at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:69)
at 
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.clean(StreamExecutionEnvironment.java:2317)
at 
org.apache.flink.streaming.api.datastream.DataStream.clean(DataStream.java:202)
at 
org.apache.flink.streaming.api.datastream.DataStream.addSink(DataStream.java:1244)
at 
org.apache.flink.streaming.api.datastream.DataStream.print(DataStream.java:937)
at test.flink.Example.main(Example.java:25)

Could anybody help give a solution on this?

I am using OpenJDK 17.

openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12-39)
OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)

Best regards,
Bill

Reply via email to