Considerations for Hive on JDK 17

Considerations for Hive on JDK 17

When configured correctly, Hive works on JDK 17, but it is still possible to encounter an error such as:
Caused by: java.lang.reflect.InaccessibleObjectException: <detailed description>: module java.base does not "opens <module name>" to unnamed module 
Here is an example of the error:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final int java.time.LocalDate.year accessible: module java.base does not "opens java.time" to unnamed module 
To fix the issue, you must add the following fix:
--add-opens java.base/<module name>=ALL-UNNAMED
For example:
--add-opens java.base/java.time=ALL-UNNAMED 
You must add the fix in two places:
  • HADOOP_OPTS variable in the hive-env.sh conf file
  • mapreduce.map.java.opts, mapreduce.reduce.java.opts, yarn.app.mapreduce.am.command-opts properties of the hive-site.xml conf file
Here is an example of making the fix:
  1. Add the following entry to the hive-env.sh file:
    export HADOOP_OPTS="-XX:+IgnoreUnrecognizedVMOptions --add-opens java.base/java.time=ALL-UNNAMED"
  2. Add the following properties to the hive-site.xml file:
    <property>
        <name>mapreduce.map.java.opts</name>
        <value>-Xmx900m --add-opens java.base/java.lang=ALL-UNNAMED -XX:+UseParallelGC --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED</value>
    </property>
    <property>
        <name>mapreduce.reduce.java.opts</name>
        <value>-Xmx2560m --add-opens java.base/java.lang=ALL-UNNAMED -XX:+UseParallelGC --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED</value>
    </property>
    <property>
        <name>yarn.app.mapreduce.am.command-opts</name>
        <value>-Xmx2560m --add-opens java.base/java.lang=ALL-UNNAMED -XX:+UseParallelGC --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens java.base/java.util.regex=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED</value>
    </property>