H2O Sparkling Water IllegalAccessError on Livy

Issue

During workflow execution on Livy, the workflow may fail with the following exception:

Received an Exception:

java.lang.IllegalAccessError: class ai.h2o.sparkling.backend.utils.RestCommunication
(in unnamed module @0x5310fffe) cannot access class
sun.net.www.protocol.http.Handler (in module java.base)
because module java.base does not export
sun.net.www.protocol.http to unnamed module @0x5310fffe

at ai.h2o.sparkling.backend.utils.RestCommunication.resolveUrl(RestCommunication.scala:312)
at ai.h2o.sparkling.backend.utils.RestCommunication.readURLContent(RestCommunication.scala:371)
at ai.h2o.sparkling.backend.utils.RestCommunication.readURLContent$(RestCommunication.scala:360)
at ai.h2o.sparkling.backend.utils.RestApiUtils$.readURLContent(RestApiUtils.scala:96)
at ai.h2o.sparkling.backend.utils.RestCommunication.request(RestCommunication.scala:182)
at ai.h2o.sparkling.backend.utils.RestCommunication.request$(RestCommunication.scala:172)

Cause

This issue occurs when running on Java 17 or later. The H2O Sparkling Water library attempts to access the internal JDK class sun.net.www.protocol.http.Handler, which is not exported by default.

Resolution

On the Execution page, In Spark Conf add the following Spark configurations:

--conf spark.driver.extraJavaOptions="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED" --conf spark.executor.extraJavaOptions="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED"

Result

After adding the above Spark configurations, run the workflow. The java.lang.IllegalAccessError should be resolved.