hmi-utwente / Flipper-2.0

Version 2.0 of the Dialogue Control system Flipper
GNU Lesser General Public License v3.0
6 stars 2 forks source link

js engine may fail to initialize #17

Open jankolkmeier opened 2 years ago

jankolkmeier commented 2 years ago

We were unable to get the latest Flipper to work for our project with ASAP.

     [java] 16:22:09.988 [main] INFO  starters.FlipperDialogStarter - Loading flipper config file: Prototype1/config/flipper.properties
     [java] 16:22:09.990 [main] INFO  starters.FlipperDialogStarter - Starting Flipper thread
     [java] Exception in thread "main" java.lang.NullPointerException
     [java]     at hmi.flipper2.javascript.JsEngine.eval(JsEngine.java:68)
     [java]     at hmi.flipper2.javascript.JsEngine.execute(JsEngine.java:56)
     [java]     at hmi.flipper2.Is.<init>(Is.java:40)
     [java]     at hmi.flipper2.TemplateController.<init>(TemplateController.java:152)
     [java]     at hmi.flipper2.TemplateController.<init>(TemplateController.java:180)
     [java]     at hmi.flipper2.TemplateController.create(TemplateController.java:100)
     [java]     at hmi.flipper2.launcher.FlipperLauncherThread.init(FlipperLauncherThread.java:132)
     [java]     at hmi.flipper2.launcher.FlipperLauncherThread.<init>(FlipperLauncherThread.java:79)
     [java]     at starters.FlipperDialogStarter.<init>(FlipperDialogStarter.java:36)
     [java]     at starters.FlipperDialogStarter.main(FlipperDialogStarter.java:103)
     [java] Java Result: 1

After some digging it seems like the engine in JsEngine is never really (successfully) initialized (i.e. here). Looks like using nashorn instead of graal.js still works fine for us (in an isolated test case). We're using the java version "1.8.0_301". Java 1.8 is recommended for ASAP at the moment.

My best explanation is that the 1.8 versions of javax.script.XXXX libs simply don't support graal.js yet? The best solution of course would be to get ASAP/hmibuild to work with a more recent version of java, but independently, maybe we can do some changes here:

jankolkmeier commented 2 years ago

Apologies. The solution for us was to manually add the graal dependencies to the ivy. (We are using flipper through the hmibuild liblocal). I guess not catching whether the engine initialized successfully (and providing the user with an insightful error message) could still be a nice improvement :)

Barachia commented 2 years ago

I once made the change to support graal.js, but didn't really look into the check for initialization. I did test Flipper with Java 11 and graal.js, so that should work at least as well.