I’m using the JavaScript support in javax.script to do some basic unit testing of JS scripts and I’ve run into a problem.
I have some code that eval(...)s the pre-requisite lib files I have in an instance of ScriptEngine, including the one that has my function blah in it.
I then eval a further file in the same instance of ScriptEngine, in which I have some functions that serve as tests, and then I invoke the tests.
However, despite all the evals working without issue, I get an error that to me suggests a problem loading the function.
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function blah. (<Unknown source>#x) in <Unknown source> at line number x
Two separate
evalcalls on the sameScriptEngineworks for me. Are you setting a newScriptContextor otherwise eliminating your definition ofblah?