Tuesday, October 15, 2013

Breakpoints in trouble - Starring Grails 2.3 and IntelliJ

The new Grails 2.3.0 GA was released lately. Since I am working on a REST API at the moment, I was curious about the REST features introduced in Grails 2.3.0. Soon after I started a little toy project, I wanted to check some controller code, but my IDE ignored all breakpoints! D'oh!

The reason seems to be another new forked execution feature shipping with the Grails 2.3.0 Version.  The gentle reader might get some background information what it's all about from this blog post by Graeme Rocher.

So if you are encountering the same problem, here is a quick fix in your BuildConfig.groovy settings to disable the forked execution and make your breakpoints work again. I got this working solution by this discussion.
The grails.project.fork config parameter to the rescue. Just set the values for test and run to false to disable forked execution like this and do a restart.

grails-app/conf/BuildConfig.groovy
grails.project.fork = [
    test: false,
    run: false
]

Other tips like appending --debug-fork to the run-app command had no effect on my project. Would be nice if you drop me a message which solution worked for you.

Don't panic and happy debugging!


10 comments:

  1. Great article and perfect solution. Thanks a bunch!

    ReplyDelete
  2. Your solution solved my problems. Thanks a buch, all frameworks have a learning curve and this was starting to become quite frustrating!

    ReplyDelete
  3. Works for us. Thanks for that!

    ReplyDelete
  4. yahoo! that was my solution Grails 2.4.2

    ReplyDelete
  5. --debug-fork dont work for me too...! i think your proposed soln is the way to go.
    Thanks

    ReplyDelete
  6. Thanks for your comments! This shows me a lot of people having still trouble with breakpoints.

    ReplyDelete
  7. Hi,
    Thanks a lot... works sweet.. only a problem though.. using this causes problem in loading external config file.
    Is there any way around ...

    ReplyDelete
  8. Sadly, with grails 2.5 and intellij 14.1, grails wont run with run: false - it gives exceptions in spring. It will run with forked mode, but as you say, its impossible to debug, even with --debug-fork

    ReplyDelete