Debugging a grails (2.3+) application can be done in two ways.
1. Simple solution: disable debug
edit BuildConfig.groovy:
grails.project.fork = [
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, fork ...
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, fork ...
to
grails.project.fork = [
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, fork ...
run: false,
Pros:
- Simple to do (and get on with your development)
Cons:
- This removes the ability to perform runtime code replacement. This means that if you change code, it will no longer be picked up automatically and you will need to restart the application to see the changes. This can be very time consuming.
2. Involved solution: debug forked runtime
This is a somewhat more complex solution where you attach a debugger to a running grails application. It is described in more detail in this blog post.
After setup you have an extra run configuration that allows you to start up grails in forked mode, and yet another extra run configuration that allows you to debug that forked mode. The catch is that you are required to start both or it does not work.
Pros:
- You have both debugging and runtime code replacement
- This does not interfere with starting the application in normal mode. (i.e. you have extra options)
Cons:
- Setting up takes a little bit of time
- Starting up in debug mode requires is a more complex two step process (i.e. it takes longer)
Considerations
Solution 2 is mostly superior in the sense that it allows flexibility. I personally don't use debug a lot, so just start in normal mode. When I want to debug, I restart in debug mode.
Solution 1 is strictly better if you need to debug and also need to restart a lot. For instance when you are working on your domain classes or database setup in your BootStrap.groovy.