Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sbt 0.13 ScriptEngine is Null for getEngineByName(“JavaScript”)

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?

like image 200
nau Avatar asked Aug 16 '26 08:08

nau


1 Answers

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.

like image 124
Seth Tisue Avatar answered Aug 19 '26 01:08

Seth Tisue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!