Debugging Grails in NetBeans 6.7 Beta

NetBeans 6.7 Beta is a great release for the Grails community.  NetBeans' support of Grails functionality is nearly on par with that of IntelliJ 8.1.  But there is one glaring omission, debugging support.  As it turns out, the NetBeans debugger does work with Grails, it just needs a little love to get it going.

Here's the steps you need to take if you wish to debug your Grails application:

  1. At the command line, navigate to your project's root folder
  2. Run the Grails' application in debug mode with the following command:

    grails-debug run-app

    The application is now up and running in debug mode, which means you may attach the NetBeans debugger on port 5005.
  3. In NetBeans, select Debug > Attach Debugger

Attach Debugger Menu Item
Figure 1.  Attach Debugger Menu Item

  1. The "Attach" dialog will appear.  Enter port number 5005.  Accept the rest of the default values.

Attach Debugger Dialog
Figure 2.  Attach Dialog

  1. Set your breakpoints and enjoy!

For more details, please see the mailing list thread at http://www.nabble.com/Debugging-Groovy-classes-in-NetBeans-td20653361.html

Comments:

Thanks

by Mustang on May 7, 2009 at 10:46 PM CDT
I had no idea there was such a feature. Thanks!

thanks

by kuba on May 9, 2009 at 5:24 AM CDT
I was looking for that very long

yes

by Ruslan on May 22, 2009 at 4:57 AM CDT
Yes

Thanks

by Sean Tindale on June 7, 2009 at 4:31 PM CDT
Thanks, good work

Works for tests too

by Sean Tindale on June 11, 2009 at 4:45 PM CDT
You can also debug your tests in this way too. Just start your app as "grails-debug test-app" and attached the debugger.

+1

by Brian LeGros on June 26, 2009 at 11:57 AM CDT
Just found this form the Grails Podcast and works great with run-app. Unfortunately I couldn't get the debugger to attach for 'test-app' using 6.7RC3 (starting debugger first or after test-app is called).

another good reference

by Brian LeGros on June 26, 2009 at 12:08 PM CDT
Looks like the debugger in Netbeans needs more time to attach than test-app currently provides. Here they talk about some great aliases which can help with debugging: http://naleid.com/blog/2009/06/14/grails-testing-command-line-aliases/

sweet

by michael kimsal on July 12, 2009 at 11:53 AM CDT
Dean - thanks so much for this quick overview - it's opened up a bunch of new doors for my grails development, and I know it'll save me a lot of time!

almost

by Roy Donasco on October 6, 2009 at 8:35 PM CDT
it was nice to debug, but what is debug if variables cannot be viewed properly. Objects in groovy are not displayed as they are coded in the watch window.

Life Saver

by Edwin on February 1, 2010 at 2:52 PM CST
Life Saver!! I almost had to go back to log statements for my Grails debugging Now I can inspect my variables with ease for this complicated data model that I have to use.

great grails blog

by Lu Li on February 5, 2010 at 1:10 AM CST
save me lots of time. Thank you very much. :)
Subject*
Name*
Comment*