对于getEngineByName(“JavaScript”),Sbt 0.13 ScriptEngine为空 [英] Sbt 0.13 ScriptEngine is Null for getEngineByName(“JavaScript”)

查看:339
本文介绍了对于getEngineByName(“JavaScript”),Sbt 0.13 ScriptEngine为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在sbt 0.13中运行使用 getEngineByName(JavaScript)的测试时,该方法返回 null
安全代码适用于sbt 0.12.x.

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.

尝试在不同的环境:Windows 7和Mac - 同样的问题。

Tried on different environments: Windows 7 and Mac - same problem.

我试图在sbt中手动设置 javaHome

I tried to manually set javaHome in sbt.

test:dependencyClasspath 包含 .ivy2 / cache / rhino / js / jars / js -1.6R7.jar

知道什么是错的吗?

推荐答案

哈哈,事实证明我几个月前自己遇到了这个问题,并且忘掉了一切!但后来我在我自己的源代码中发现了这个:

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")

因此将null传递给ScriptEngineManager构造函数是修复...

So passing null to the ScriptEngineManager constructor is the fix...

...但我不能忽视根本原因,除非我打赌这是一个类加载器的事情。请注意, fork in run:= true 也会使问题消失。

...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.

这篇关于对于getEngineByName(“JavaScript”),Sbt 0.13 ScriptEngine为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆