You only need to add --add-opens java.base/java.lang=ALL-UNNAMED to the environment variable HADOOP_OPTS to resolve the issue in your Hadoop 3.4.1 and JDK 17 environment.
--add-opens java.base/java.lang=ALL-UNNAMED
HADOOP_OPTS