Debugging NK4 groovy scripts in IDEA

Poster Content
nk4um Moderator
Posts: 755
July 22, 2010 13:12
Hi Mircea,

Yes this is because the Groovy runtime dynamically compiles and executes the scripts.  As far as we are aware when using Groovy like this (ie a truely dynamic language) you can''t attach the Java debugger.

My guess is that IDEs supporting groovy are actually compiling it to Java classes - and using regular Java debugging.

Its an interesting challenge - since in the ROC world source code is a resource, it may not even have a physical file for the Java debugger to link against.  Its analogous to when you try and debug a class and give the IDE source that is not in step and the debugger line marker bears no relation to the breakpoint.

So the solution, when using scripting languages is to use copious logging/println.  Or, if what you''re doing does not need the flexibility of a dynamic language - you can always compile the Groovy with groovyc.  The NK classloader won''t care - it''s all just classes.

Cheers,

Peter
nk4um User
Posts: 26
July 21, 2010 01:21Debugging NK4 groovy scripts in IDEA
Hi,

I try to remote debug groovy scripts written for a NK4 module. My remote debug configuration in IDEA connects successfully to the remote NK4 process. NK process is listening on the proper port for debug connections.

I set a breakpoint in my script, then asked for an appropriate resource in the browser; my breakpoint was supposed to be hit; nothing happened though.

The debugging process described above works fine for java accessors.

Any idea why groovy scripts written for NK cannot be debugged? Not being able to debug groovy scripts would make me write mostly java accessors...

Best regards,
Mircea