0

I am trying to write a java wrapper to use my h2o mojo model. When I load my model zip files in, I receive a null pointer exception. Below is a sample of my code:

public static void main(String[] args) throws Exception {
    EasyPredictModelWrapper predict_model = new EasyPredictModelWrapper(
      MojoModel.load("prediction_football_model.zip"));
    EasyPredictModelWrapper class_model = new EasyPredictModelWrapper(
      MojoModel.load("classification_football_model.zip"));   
  }

and error Message:

Exception in thread "main" java.lang.NullPointerException: entry
    at java.util.zip.ZipFile.getInputStream(ZipFile.java:346)
    at hex.genmodel.ZipfileMojoReaderBackend.getTextFile(ZipfileMojoReaderBackend.java:18)
    at hex.genmodel.ModelMojoReader.parseModelInfo(ModelMojoReader.java:154)
    at hex.genmodel.ModelMojoReader.readFrom(ModelMojoReader.java:27)
    at hex.genmodel.MojoModel.load(MojoModel.java:35)
    at GamePrediction.main(GamePrediction.java:52)

I have been working on this code in eclipse and I have placed both of the zip files in the main project folder. I created the models in R using the h2o.download_mojo() function. I looked into the error message and found that my ZipEntry for the given path's were Null, but I could not find a solution to that.

Any help or insight would be helpful. I couldn't find any other issues like this so if this is a duplicate, please point me to the right direction!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Joey Bloom
  • 33
  • 3
  • 1) See [What is a stack trace, and how can I use it to debug my application errors?](http://stackoverflow.com/q/3988788/418556) & [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/q/218384/418556) 2) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 3) My first thought would be that **the files are not where the JVM is expecting them to be.** Are they an inherent part of the application (supplied by you)? – Andrew Thompson Jul 22 '18 at 23:04
  • Not sure if this is the cause, but make sure you get the `h2o-genmodel.jar` by setting `get_genmodel_jar = TRUE` in `h2o.download_mojo()`. – Erin LeDell Jul 22 '18 at 23:14
  • I did use the gen_genmodel_jar and the files are generated from the h2o library in R, but are then stored as zip files locally on my computer – Joey Bloom Jul 23 '18 at 02:58

1 Answers1

0

I got the same error and resolved it.

In my case, the mojo runtime file had a problem. I was using 1.8.1.1, and a bug discovered around the time of the version. I simply replaced the file with the latest one. Then everything worked like a charm.

Here is the link for the file. Please notice that this may not be the latest one for you. https://s3.amazonaws.com/artifacts.h2o.ai/releases/ai/h2o/mojo2-runtime/2.5.9/any/mojo2-runtime-2.5.9-all.jar

Jeong Kim
  • 481
  • 3
  • 9
  • 21