ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacopo Cappellato <jacopo.cappell...@hotwaxmedia.com>
Subject Re: Unable to debug groovy script called by screen widget
Date Fri, 13 Apr 2012 09:40:52 GMT
Leon, all,

until we find a good solution I can share the following patch/tweak for data preparation scripts
(screen, forms etc...):

Index: framework/base/src/org/ofbiz/base/util/ScriptUtil.java
===================================================================
--- framework/base/src/org/ofbiz/base/util/ScriptUtil.java	(revision 1325649)
+++ framework/base/src/org/ofbiz/base/util/ScriptUtil.java	(working copy)
@@ -336,6 +336,9 @@
      */
     public static Object executeScript(String filePath, String functionName, Map<String,
Object> context, Object[] args) {
         try {
+            if (filePath.endsWith(".groovy")) {
+                return GroovyUtil.runScriptAtLocation(filePath, context);
+            }
             return executeScript(filePath, functionName, createScriptContext(context), args);
         } catch (Exception e) {
             String errMsg = "Error running script at location [" + filePath + "]: " + e.toString();


This will enable the ability to debug the code because it will execute groovy data preparation
scripts using GroovyUtil rather than JSR223

Adrian, any idea on how we could improve this in a nicer way to address the issue?

Jacopo


On Apr 12, 2012, at 3:47 PM, Jacopo Cappellato wrote:

> You can now use a debugger for Groovy services and events; for details see rev.  1325253.
> This is not available for data preparation scripts (screens).
> 
> Jacopo
> 
> On Apr 12, 2012, at 10:11 AM, Jacopo Cappellato wrote:
> 
>> Unfortunately yes, it is a very bad side effect of the switch to JSR 223.
>> This also affects the events and services implemented in Groovy but for them I am
working at a workaround now (I should be able to commit a fix probably today).
>> For data preparation scripts... I didn't look at them deeply so I don't have a solution,
but it is something we will have to fix, otherwise I think we should switch back to a Groovy
specific invoker.
>> 
>> Jacopo
>> 
>> On Apr 5, 2012, at 6:18 AM, Leon wrote:
>> 
>>> In eclipse, it doesn't work if I set breakpoint in the groovy script which is
>>> called internally via <script> tag in screen widget. But if I call this
>>> script via "GroovyUtil.runScriptAtLocation" directly, then the execution is
>>> paused at that point as expected.
>>> 
>>> Is this the side effect of script refactoring? I remeber it worked very well
>>> some days ago.
>>> 
>>> --
>>> View this message in context: http://ofbiz.135035.n4.nabble.com/Unable-to-debug-groovy-script-called-by-screen-widget-tp4533949p4533949.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>> 
> 


Mime
View raw message