app-gradle-plugin: java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/NashornScriptEngineFactory when running locally

Catching this exception in a project which uses Nashorn when trying to run gradle appengineRun. But deployed version works fine!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (14 by maintainers)

Most upvoted comments

@vh Is that already fixed? I probably ran into this again here: https://github.com/jknack/handlebars.java/issues/652

new ScriptEngineManager().getEngineByName("nashorn");

returns null in local devserver, but works in tests and also in production.

I created a dedicated repo for that issue here: https://github.com/mpoehler/hbs-test

Can you give me a hint regarding the classloading issue in the devserver?

@loosebazooka Yes. I’ve found that it is problem with local dev classloader. Not gradle plugin issue. Thanks for help!

@vh, using (null is important here)

ScriptEngine engine = new ScriptEngineManager(null).getEngineByName("nashorn");

instead of

engine = (NashornScriptEngine)new NashornScriptEngineFactory().getScriptEngine();

seems to make it work. I’m not familiar with ScriptEngines, but could that be part of it?