Sbt 0.13 ScriptEngine is Null for getEngineByName(“JavaScript”)
javascript, sbt, scala
Solution
Haha it turns out I had this problem myself a few months ago, and forgot all about it! But then I found this just now in my own source code:
// the (null) became necessary when we upgraded to sbt 0.13. I don't understand why.
// classloaders, go figure! - ST 8/26/13
val engine =
(new javax.script.ScriptEngineManager(null))
.getEngineByName("rhino")
.ensuring(_ != null, "JavaScript engine unavailable")
So passing null to the ScriptEngineManager constructor is the fix...
...but I can't shed on any light on the underlying cause, except that I bet it's a classloader thing. Note that `fork in run := true` also makes the problem go away.
Problem
When I run tests which use `getEngineByName("JavaScript")` in sbt 0.13 the method returns `null`. The safe code works fine with sbt 0.12.x. Tried on different environments: Windows 7 and Mac - same problem. I tried to manually set `javaHome` in sbt. `test:dependencyClasspath` contains `.ivy2/cache/rhino/js/jars/js-1.6R7.jar` Any idea what's wrong?