I can't debug my code in Intellij IDEA. When debug mode is active and running, but the breakpoints don't have that "v" checked that represents a valid and stoppable breakpoint.
See the image: http://prntscr.com/1w0owu.
I really search on the web for an answer. What I suppose to do?
Did you see this article? It details the how to step by step and got me past my problem.
http://mrhaki.blogspot.com/2013/12/grails-goodness-debugging-app-in-forked.html
This should not ever be the default configuration and only be left to the individual's choice. It's a freakin pain to do two configurations just get this thing running in debug mode in intellij. First you have to setup or modify the normal run configuration by adding "--debug-fork" after run-app. Second, you have to configure remote debugging , while accepting all the defaults. Then you have to run the run configuration, and when that's running, you run the debug configuration. What a pain. I prefer totally doing away with running without the forked option while developing. Time is money and I don't have time to monkey around. See Mr.HAKI explanation on doing this. http://blog.jdriven.com/2013/12/grails-goodness-debugging-app-forked-mode/
Since Grails 2.3, forked execution for several Grails commands (e.g.
run-app
,test-app
) was introduced. If you just debug a Grails application from IntelliJ IDEA, theGrailsStarter
process will be started with debug options on. The output on the IDEA console will be:The application itself will be started in a separate process named
ForkedTomcatServer
. This is where your code runs and where your debugger should actually connect to.To accomplish that, set
debug: true
inBuildConfig.groovy
at therun
configuration ofgrails.project.fork
. Just run Grails now from IDEA (do not debug) and you will see the following line in the console when the application is ready to serve HTTP requests:This is where you want to direct a separate remote run configuration to. As soon as your remote debugger connected, issue a HTTP request and debugging will work.
You can also disable forked execution for compile/test/run/war/console Grails commands entirely by setting the value associated with the command entry in
grails.project.fork
tofalse
. But then you will lose the benefits for forked execution added in Grails 2.3.None of the other answers work for me on Grails 3.x in 2016 w/ Intellij 15.0.4. This does work for me:
Start grails in intellij with this command:
The console should output: "Listening for transport dt_socket at address: 5005 Grails application running at http://localhost:8080 in environment: development"
Now you can add a new configuration of type, "Remote", in Intellij. Then start it with its defaults.
And the new debug console window should write: "Connected to the target VM, address: 'localhost:5005', transport: 'socket'"
Done.
For those interested, the reference to grails 3.x documentation for starting a debuggable server is at section 2.8, runningAndDebuggingAnApplication:
http://grails.github.io/grails-doc/3.1.x/guide/gettingStarted.html#runningAndDebuggingAnApplication
"There are several ways to execute the Application class, if you are using an IDE then you can simply right click on the class and run it directly from your IDE which will start your Grails application. This is also useful for debugging since you can debug directly from the IDE without having to connect a remote debugger when using the run-app --debug-jvm command from the command line."
Important Note. When I tried the "simply right click on the class and run it directly from your IDE", the app did start. However, all requests I sent to my controller resulted in 500 errors with message: "Could not resolve view with name '/myendpoint' in servlet with name 'grailsDispatcherServlet'.
So, I reverted back to the instructions above.
Checkout this blog about Debugging Grails Forked Mode.