NashornScriptEngine errors with JRE 8

620 views
Skip to first unread message

Joshua Hansen

unread,
Jan 19, 2015, 7:22:39 PM1/19/15
to mir...@googlegroups.com
Hi all,

We are encountering an issue with Mireka "Quick Start" and JRE 8.  No issues w/ JRE 7.

2015-01-19 15:13:17,603 [   ] [main]                  INFO  mireka.startup.Start Starting Mireka 4.1.1...
2015-01-19 15:13:18,056 [   ] [main]                  DEBUG m.startup.ScriptApi Evaluating conf\mireka.js...
2015-01-19
 
15:13:18,071 [   ] [main]                  ERROR mireka.startup.Start
Cannot read configuration. Include stack: [conf\mireka.js]
javax
.script.ScriptException: TypeError:
mireka
.startup.ScriptApi@6c130c45 has no such function "include" in
conf
\mireka.js at line number 7
    at jdk
.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:586)
    at jdk
.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:570)
    at jdk
.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:525)
    at jdk
.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:521)
    at jdk
.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:187)
    at javax
.script.AbstractScriptEngine.eval(Unknown Source)
    at mireka
.startup.ScriptApi.include(ScriptApi.java:50)
    at mireka
.startup.Start.configure(Start.java:45)
    at mireka
.startup.Start.main(Start.java:31)
Caused
 
by: jdk.nashorn.internal.runtime.ECMAException: TypeError:
mireka
.startup.ScriptApi@6c130c45 has no such function "include"
    at jdk
.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:58)
    at jdk
.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:214)
    at jdk
.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:186)
    at jdk
.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:173)
    at jdk
.nashorn.internal.runtime.linker.NashornBottomLinker.linkBean(NashornBottomLinker.java:118)
    at jdk
.nashorn.internal.runtime.linker.NashornBottomLinker.getGuardedInvocation(NashornBottomLinker.java:73)
   
 at
jdk
.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
    at jdk
.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:144)
    at jdk
.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:232)
    at jdk
.nashorn.internal.scripts.Script$mireka.runScript(conf\mireka.js:7)
    at jdk
.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:535)
    at jdk
.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:209)
    at jdk
.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
    at jdk
.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:568)
   
... 7 common frames omitted

System:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

This is on Windows 7 Pro 64-bit.

Perhaps related to a change from JRE 7 to 8 where the Mozilla Rhino engine was replaced by Oracle Nashorn. 

The following links might be useful.

Rhino Migration Guide
https://wiki.openjdk.java.net/display/Nashorn/Rhino+Migration+Guide

Oracle Nashorn: A Next-Generation JavaScript Engine for the JVM

http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html

Nashorn: The New Rhino on the Block

http://ariya.ofilabs.com/2014/03/nashorn-the-new-rhino-on-the-block.html
* Links to a speed test sample which invokes both Rhino and Nashorn engines.

Java 8 Nashorn Tutorial

http://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/

Josh

Jacob Richardson

unread,
Feb 18, 2015, 4:51:37 PM2/18/15
to mir...@googlegroups.com
We are having same issue. Has anyone solved this problem?
...

HONTVÁRI Levente

unread,
Feb 18, 2015, 6:07:02 PM2/18/15
to mir...@googlegroups.com
This is caused by the upgrade from Rhino to Nashorn in JDK 8. The Javascript engine is not part of the JRE, only an addon to the JDK, it is not required to maintain compatibility.

Fixing this maybe only requires a single line to include the compatibility script (preferably conditionally, depending on the JavaScript engine),
load("nashorn:mozilla_compat.js");

If this does not work, than I have to bundle Rhino.
--

---
You received this message because you are subscribed to the Google Groups "Mireka mail server and SMTP proxy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mireka+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joshua Hansen

unread,
Feb 19, 2015, 4:11:19 PM2/19/15
to mir...@googlegroups.com
Hi Levente,


On Wednesday, February 18, 2015 at 11:07:02 PM UTC, Levente wrote:
This is caused by the upgrade from Rhino to Nashorn in JDK 8. The Javascript engine is not part of the JRE, only an addon to the JDK, it is not required to maintain compatibility.

Fixing this maybe only requires a single line to include the compatibility script (preferably conditionally, depending on the JavaScript engine),
load("nashorn:mozilla_compat.js");

If this does not work, than I have to bundle Rhino.

I think I tried the 'mozilla_compat.js', and it got things a little further, but there were still problems.

This article covers using Rhino with JDK 8:
https://wiki.openjdk.java.net/display/Nashorn/Using+Rhino+JSR-223+engine+with+JDK8

I haven't tried it (we aren't using JDK 8 for development yet), but it might provide an interrim solution for people who need to get it working.

BTW, Mireka is great stuff -- it's something I've wanted for development for 8+ years.  Nice work!

Josh
 

Jacob Richardson

unread,
Feb 19, 2015, 5:15:22 PM2/19/15
to mir...@googlegroups.com
See links below for solution. You need to add two jars to the Mireka lib folder to support Rhino. This is an interim solution. Not sure if Mireka is going to be supported long term.

Jacob Richardson

unread,
Feb 19, 2015, 5:24:27 PM2/19/15
to mir...@googlegroups.com
I forgot to mention in previous post that you need to edit mireka.startup.Start.java;  In Configure method Change ScriptApi.engine = factory.getEngineByName("JavaScript") line to
ScriptApi.engine = factory.getEngineByName("rhino");


On Wednesday, February 18, 2015 at 6:07:02 PM UTC-5, Levente wrote:
Reply all
Reply to author
Forward
0 new messages