Marco
Marco

Reputation: 15929

Debug a Grails 3.x application

I am trying to debug a Grails 3.x application using grails run-app --debug-fork. But when the application starts it does not wait for the debugger to attach. Any solution on how to debug a Grails 3.x application?

Upvotes: 13

Views: 5015

Answers (4)

jmorhardt
jmorhardt

Reputation: 183

In IntelliJ IDEA 2016.1, I create two configurations. This allows me to make solid use of all the context menus, etc. that IntelliJ IDEA offers. Here's how:

  1. The first configuration is a "Run" configuration. Edit the default configuration and in the "Command Line" field, enter run-app --debug-jvm
  2. The second configuration is a "Remote" configuration. On the "Run/Debug" dialog, click the + symbol and select "Remote" from the list. Name it "Debug" and save.
  3. Select your "Run" config from the config dropdown at the top and then click the green arrow to run the app. Monitor the console output until you see the message Listening for transport dt_socket at address: 5005.
  4. Select the remote debug profile you created in step 2 and click the debug button. In a few moments the console output will say Grails application running at http://localhost:8080 in environment: development.

Success!

Upvotes: 3

rlovtang
rlovtang

Reputation: 5060

In IntelliJ you can right click the Gradle task bootRun and select Debug.

Upvotes: 11

rzymek
rzymek

Reputation: 9281

The other option is to directly run the Application class located in grails-app/init. It has a static void main and be run as a regular application. You can run it directly from your IDE with a debug profile.

Upvotes: 3

pablovilas
pablovilas

Reputation: 613

Please use the --debug-jvm flag. For example: grails --debug-jvm run-app

Upvotes: 20

Related Questions