Debugging your Grails 3.0.x application

Every new version of Grails brings some enhancements, and challenges on developer side too. Starting Grails 2.3.x, we had to change our approach to use debugger with our application, and with Grails 3.x coming out, we need to change approach to use debugger again.

As Grails now uses Spring Boot and Gradle, we have to hook into bootRun gradle task that gets added by Spring Boot Gradle plugin. We can customize it by adding this task to build.gradle file, as follows:

[sourcecode language=”java”]
bootRun {
addResources = false // We can set it to true if we would like to reload src/main/resources
jvmArgs = ["-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"]
}
[/sourcecode]

Now follow the steps below:

  1. Add a remote configuration inside your IDE that would attach your debugger to that port.
  2. Go to terminal, execute grails run-app and wait for prompt that says Listening for transport dt_socket at address: 5005.
  3. Now just hit debug toolbar symbol on your IDE.

You’re again debugging your Grails application!

 

FOUND THIS USEFUL? SHARE IT

comments (1 “Debugging your Grails 3.0.x application”)

  1. Manish Arora

    Hi,

    While doing the remote configuration I am not able to select any project.It show empty popup.

    Please let me know how to proceed on this.

    Thanks,
    Manish

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *