playframework/playframework — pull request #3420 by jroper (2014-10-01 07:27:15+00:00)
Title: JDK8's Nashorn classes can't be loaded in a Play app during dev

I've seen some references to this issue (#2948, #2532), but they just ended in workarounds that don't work for many cases.

It looks like no classes inside `jdk.nashorn.*` can be loaded by the default classloader while running a Play app in dev mode.

To repro, take the basic Play Scala template and change `Application.index`:

```scala
def index = Action {
jdk.nashorn.api.scripting.ScriptUtils.wrap(null)
Ok(views.html.index("Your new application is ready."))
}
```

When you `activator run` and view the webpage, you get this error:

```
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/ScriptUtils]]
at play.api.Application$class.handleError(Application.scala:296) ~[na:na]
at play.api.DefaultApplication.handleError(Application.scala:402) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:205) [na:na]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$14$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:202) [na:na]
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [na:na]
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/ScriptUtils
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523) ~[na:na]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[na:na]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[na:na]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[na:na]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129) ~[na:na]
Caused by: java.lang.NoClassDefFoundError: jdk/nashorn/api/scripting/ScriptUtils
at controllers.Application$$anonfun$index$1.apply(Application.scala:11) ~[na:na]
at controllers.Application$$anonfun$index$1.apply(Application.scala:10) ~[na:na]
at play.api.mvc.ActionBuilder$$anonfun$apply$17.apply(Action.scala:464) ~[na:na]
at play.api.mvc.ActionBuilder$$anonfun$apply$17.apply(Action.scala:464) ~[na:na]
at play.api.mvc.ActionBuilder$$anonfun$apply$16.apply(Action.scala:433) ~[na:na]
Caused by: java.lang.ClassNotFoundException: jdk.nashorn.api.scripting.ScriptUtils
at org.aspectj.weaver.bcel.ExtensibleURLClassLoader.findClass(ExtensibleURLClassLoader.java:54) ~[na:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_20]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_20]
at controllers.Application$$anonfun$index$1.apply(Application.scala:11) ~[na:na]
at controllers.Application$$anonfun$index$1.apply(Application.scala:10) ~[na:na]
```