groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harish Dewan <>
Subject Re: ScriptException does not prints actual file name
Date Sun, 19 Mar 2017 16:29:20 GMT
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

again if i re run the same code, it just increments the Script<unique
number> i.e Script4, Script5 and so on.

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)
ScriptContext context = engine.getContext();
context.setAttribute(ScriptEngine.FILENAME, "hello.groovy",

Reader r = new FileReader("<path to hello.groovy file>");
catch (ScriptException e)

I did tried looking into source code and in class
'' in function getScriptClass,
while it is trying to parse class
 clazz = loader.parseClass(script, generateScriptName());

 generate script name always increments the counter, there is no reference
of getting name from context.
  // generate a unique name for top-level Script classes
    private synchronized String generateScriptName() {
        return "Script" + (++counter) + ".groovy";
Kindly guide.


On Fri, Mar 17, 2017 at 4:48 PM, Edmond Kemokai <> wrote:

> Hi Harish,
> The <unique number> should be the line number where the problem is. How
> are you setting context that doesn't show file name? The code you're
> running that has the error can't possibly extract something from the
> context since there is an error (I am guessing syntax error?).
> I am the developer of HiveMind, it is a JSR223 based web app platform for
> Groovy and other JVM languages. You can access:
> url:
> login: developer/developer
> I have created a test file in: /com/crudzilla/cloudTest/web/dewan/test.ste
> You can test the code by right clicking on the test.ste file and selecting
> "Open In Browser".
> Put your code in there and save, I can review it for you.
> -Edmond
> On Fri, Mar 17, 2017 at 6:47 AM, Harish Dewan <>
> wrote:
>> Hi All,
>> I am trying to run a groovy script from my Java code using JSR223 and I
>> am using 'groovy-all-2.4.9.jar' .
>> In case of any exception occurring, it gives a generic name as
>> Script<unique number>.groovy , where as the script file name was
>> differently given.
>> I checked for possible solutions, like I need to set the script file name
>> in the context. but the current code for eval does not gets the script file
>> name from context. It creates a unique file name through
>> 'generateScriptName'.
>> Is this a bug or do I need to deal with it differently ?
>> Please guide.
>> Thanks
>> Harish

View raw message