Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A2B1F200C37 for ; Sun, 19 Mar 2017 17:29:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A11D4160B7D; Sun, 19 Mar 2017 16:29:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A0F9C160B6D for ; Sun, 19 Mar 2017 17:29:31 +0100 (CET) Received: (qmail 16488 invoked by uid 500); 19 Mar 2017 16:29:25 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 16471 invoked by uid 99); 19 Mar 2017 16:29:25 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 19 Mar 2017 16:29:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5E5E51A0092 for ; Sun, 19 Mar 2017 16:29:25 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.38 X-Spam-Level: ** X-Spam-Status: No, score=2.38 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, WEIRD_PORT=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id MlQ2H2E3gZKQ for ; Sun, 19 Mar 2017 16:29:23 +0000 (UTC) Received: from mail-it0-f51.google.com (mail-it0-f51.google.com [209.85.214.51]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id AB0875F403 for ; Sun, 19 Mar 2017 16:29:22 +0000 (UTC) Received: by mail-it0-f51.google.com with SMTP id g138so72646264itb.0 for ; Sun, 19 Mar 2017 09:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=AzhAYgqEQdRHdJ2+4DosOydLFBo61+9vi0Abx5IS/aQ=; b=gV7ygb29gC2/1EZBG5K1wSWu7tNVCuvH2u12KSvK9C6QHxgjEjf17jiwKaV91m2drt u5trBGjl4THJGXf1DoEHVfhjohkhlnhAi8Mzw+E2b/N5gqy+htPu9PkxcivTNXEB+k/U wMVO2hKcRDxvJydZSlh6tvXAckQ6v3tJ2RLOfF/QajVNjt7EgHObMsgY2EguMwt7y39O fgxD4BlRpk5/1RuAWknpdYYqLsKlx73Ih+ZDTUaK0AS7viJZ/F2ymEPknOoydkNij7WQ mTyVjh98gAJiwBHPvWN6YBgcxj13Q36UAdH3gpBWMddeHPsULf3X/KqI7uKhz6lejybz vzPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=AzhAYgqEQdRHdJ2+4DosOydLFBo61+9vi0Abx5IS/aQ=; b=mfPlRflgZYhw7kBP3Wbr+1yiVYaFhJ8PFxC3LXDtXSFoAv2rerUmgD2nfUYc7RW9+L nJCimsl78paVqiHIh9FRCohWilWn1z0wBrdi1BmQRI+ODwJlSh9xwA6C0wn/Il0SBzSE GPjtPlGtwiVyE/QEIx98l3S/c0X2DdESc0s79761+lcxOwPbU4ITY8w8Ie1UTyRK8lHK rAq4dfkrEt7Pe1P5tVxp6SmxBEPrVU6Ihg5LfoSzj4m5Cl9T9TjI/xVcsEF52qXlB3sd /t4gb4KkOs9xbcNtTUCLDINghEbe/y60aRMr5i2FCT/cS4WqYSCzjcS/AED4h+eqrM2N GUCg== X-Gm-Message-State: AFeK/H2aWCzzuWHz0YdSdGiAU6Equ7OGy0dJRZw3kLrWV13b5BW6Ff8VvaGOtyLgchCOcMWySbUaO+1wTyK89w== X-Received: by 10.107.189.68 with SMTP id n65mr23482845iof.154.1489940961293; Sun, 19 Mar 2017 09:29:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.200.5 with HTTP; Sun, 19 Mar 2017 09:29:20 -0700 (PDT) In-Reply-To: References: From: Harish Dewan Date: Sun, 19 Mar 2017 21:59:20 +0530 Message-ID: Subject: Re: ScriptException does not prints actual file name To: users@groovy.apache.org Content-Type: multipart/alternative; boundary=94eb2c077912bc2059054b17e980 archived-at: Sun, 19 Mar 2017 16:29:32 -0000 --94eb2c077912bc2059054b17e980 Content-Type: text/plain; charset=UTF-8 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 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) .getEngineByExtension(extension); ScriptContext context = engine.getContext(); context.setAttribute(ScriptEngine.FILENAME, "hello.groovy", ScriptContext.ENGINE_SCOPE); Reader r = new FileReader(""); try { engine.eval(r,context); } catch (ScriptException e) { } I did tried looking into source code and in class 'GroovyScriptEngineImpl.java' 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. Thanks Harish On Fri, Mar 17, 2017 at 4:48 PM, Edmond Kemokai wrote: > Hi Harish, > > The 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: http://demo.crudzilla.com:7000/ > 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.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 >> >> > > > --94eb2c077912bc2059054b17e980 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Edmond,
thanks for your reply.
the unique number which i was talking about is not the line number.=C2=A0<= /div>
for example: below is an script exception thrown in case of synta= x error.=C2=A0
I had introduced text 'abcd' in my hello.g= roovy script.
in case of exception it says below message

javax.script.ScriptException: groovy.lang.MissingPropertyE= xception: 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 e= xpecting error message of type=C2=A0
javax.script.ScriptException= : groovy.lang.MissingPropertyException: No such property: abcd for class: h= ello.groovy
=C2=A0
I am setting the context as follows<= /div>

ScriptEngine engine =3D new ScriptEngineManager(lo= ader)
.getEngineByExtension(extension);
Script= Context context =3D engine.getContext();
context.setAttr= ibute(ScriptEngine.FILENAME, "hello.groovy", ScriptContext.ENGINE= _SCOPE);

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

I did tried looking into sourc= e code and in class 'GroovyScriptEngineImpl.java' in function getSc= riptClass,=C2=A0
while it is trying to parse class=C2=A0
=C2=A0clazz =3D loader.parseClass(script, generateScriptName());
=C2=A0
=C2=A0generate script name always increments the counter= , there is no reference of getting name from context.
=C2=A0 // g= enerate a unique name for top-level Script classes
=C2=A0 =C2=A0 = private synchronized String generateScriptName() {
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 return "Script" + (++counter) + ".groovy"= ;
=C2=A0 =C2=A0 }
Kindly guide.

=
Thanks
Harish

On Fri, Mar 17, 2017 at 4:48 PM, Edmond Kemokai <e= kemokai@gmail.com> wrote:
<= div dir=3D"ltr">
Hi Harish,

The <unique numbe= r> should be the line number where the problem is. How are you setting c= ontext that doesn't show file name? The code you're running that ha= s the error can't possibly extract something from the context since the= re is an error (I am guessing syntax error?).

I am the develop= er of HiveMind, it is a JSR223 based web app platform for Groovy and other = JVM languages. You can access:

url: http://demo.crudzilla.com:7000/
<= /div>login: developer/developer

I have created a tes= t file in: /com/crudzilla/cloudTest/web/dewan/test.ste

You can test the code by right clicking on the test.ste file and selecti= ng "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 <harish.dewan@gmail.com= > wrote:
Hi All,
I am trying to run a groovy script from my Ja= va code using JSR223 and I am using 'groovy-all-2.4.9.jar' .
<= div>In case of any exception occurring, it gives a generic name as Script&l= t;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 'g= enerateScriptName'.

Is this a bug or do I need to deal wit= h it differently ?=C2=A0
Please guide.

Thanks=C2=A0=
Ha= rish




=
--94eb2c077912bc2059054b17e980--