While executing the following line my server halted for the second request.
Invocable invocableEngine = load();
Object o1 = invocableEngine.invokeFunction("add",5,6,jsonObj);
private static Invocable invocable =null;
public static Invocable load() throws ScriptException, NoSuchMethodException, FileNotFoundException {
if(invocable!=null){
return invocable;
}
File jsFile = new File("test.js");
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jav8"); //No I18N
Reader reader = new FileReader(jsFile);
engine.eval(reader);
invocable = (Invocable) engine;
return invocable;
}
test.js
add = function(a, b) {
return a + b;
}
I dont want to evaluate the js for each request, so that i used the Invocable as static.
This is the error thrown in the console
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x0000000121d6f4b4, pid=791, tid=33539
JRE version: Java(TM) SE Runtime Environment (8.0_25-b17) (build 1.8.0_25-b17) Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode bsd-amd64 compressed oops) Problematic frame: C [libjav8651059438244345661.dylib+0x184b4] _ZN2v811HandleScopeC1Ev+0x84
Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
An error report file with more information is saved as: hs_err_pid791.log
If you would like to submit a bug report, please visit:
http://bugreport.sun.com/bugreport/crash.jsp The crash happened outside the Java Virtual Machine in native code. See problematic frame for where to report the bug.