H2O failed to connect in R

Viewed 1262

I am nt able to start the h2o in R due to version of java and receiving the below error

H2O is not running yet, starting it now...

Note: In case of errors look at the following log files: C:\Users\Vaibhav\AppData\Local\Temp\RtmpMBUt0r\file1db069d01678/h2o_Vaibhav_started_from_r.out C:\Users\Vaibhav\AppData\Local\Temp\RtmpMBUt0r\file1db02fcb36fc/h2o_Vaibhav_started_from_r.err

java version "14.0.1" 2020-04-14 Java(TM) SE Runtime Environment (build 14.0.1+7) Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

Starting H2O JVM and connecting: ............................................................Diagnostic HTTP Request: HTTP Status Code: -1 HTTP Error Message: Failed to connect to localhost port 54321: Connection refused

Error Output: Only Java 8, 9, 10, 11, 12 and 13 are supported, system version is 14.0.1 Error in h2o.init(nthreads = -1, max_mem_size = "4g") : H2O failed to start, stopping execution

2 Answers

you're using Java version 14, which is not yet supported officially in H2O.

There's a JIRA to track Java 14 integration: https://0xdata.atlassian.net/browse/PUBDEV-7647 .

In H2O, there's a property to override this default setting, which will let you use H2O with Java 14 at your own risk. This can be done by settings the sys.ai.h2o.debug.allowJavaVersions property when starting H2O.

  • If started manually, use java -Dsys.ai.h2o.debug.allowJavaVersions=14 -jar h2o.jar
  • From Python, use: h2o.init(jvm_custom_args=["sys.ai.h2o.debug.allowJavaVersions", "14"])
  • From R, use: h2o.init(jvm_custom_args=c("sys.ai.h2o.debug.allowJavaVersions", "14"))

I was able to get H2O working with Java 14 by following the install instructions for the latest stable release (currently rel-zeno/2):

# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }

# Next, we download packages that H2O depends on.
pkgs <- c("RCurl","jsonlite")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}

# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-zeno/2/R")

# Finally, let's load H2O and start up an H2O cluster
library(h2o)
h2o.init()

You'll need to update the repos URL in the last install.packages line if you want a more recent release.

When I tried the answer from @pavel-pscheidl (prior to trying the above) I got the following error:

> h2o.init(jvm_custom_args=c("sys.ai.h2o.debug.allowJavaVersions", "14"))

H2O is not running yet, starting it now...

Note:  In case of errors look at the following log files:
    /var/folders/nx/pn7rnnx96f184jt2sdtm52_00000gp/T//RtmpTz7jEz/file88837ecffee3/h2o_username_started_from_r.out
    /var/folders/nx/pn7rnnx96f184jt2sdtm52_00000gp/T//RtmpTz7jEz/file88839672a20/h2o_username_started_from_r.err

openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

Starting H2O JVM and connecting: ............................................................Diagnostic HTTP Request:
   HTTP Status Code: -1
HTTP Error Message: Failed to connect to localhost port 54321: Connection refused
 
Error Output:
   Error: Could not find or load main class sys.ai.h2o.debug.allowJavaVersions
   Caused by: java.lang.ClassNotFoundException: sys.ai.h2o.debug.allowJavaVersions 
Error in h2o.init(jvm_custom_args = c("sys.ai.h2o.debug.allowJavaVersions",  : 
  H2O failed to start, stopping execution.
Related