On 19.03.2017 17:29, Harish Dewan wrote:
Hi Edmond,
thanks for your reply.
the unique number which i was talking about is not the line number.
for example: below is an script exception thrown in case of syntax error.
I had introduced text 'abcd' in my hello.groovy script.
in case of exception it says below message

javax.script.ScriptException: groovy.lang.MissingPropertyException: No
such property: abcd for class: Script3

in general the name of a script depends on how it is "loaded". These automatic names are normally for scripts without file in which the script is given in as String, Reader, InputStream or something like that.

I was expecting error message of type
javax.script.ScriptException: groovy.lang.MissingPropertyException: No
such property: abcd for class: hello.groovy
I am setting the context as follows

ScriptEngine engine = new ScriptEngineManager(loader)
.getEngineByExtension(extension);
ScriptContext context = engine.getContext();
context.setAttribute(ScriptEngine.FILENAME, "hello.groovy",
ScriptContext.ENGINE_SCOPE);

Reader r = new FileReader("<path to hello.groovy file>");
try
{
engine.eval(r,context);
}
catch (ScriptException e)
{
}

I guess that means ScriptEngine.FILENAME is ignored.

bye Jochen

Reply via email to