IntelliJ IDEA Debugger isn't working on a Grai

2019-01-16 14:24发布

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?

11条回答
SAY GOODBYE
2楼-- · 2019-01-16 14:44

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

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-16 14:45

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/

查看更多
我命由我不由天
4楼-- · 2019-01-16 14:50

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, the GrailsStarter process will be started with debug options on. The output on the IDEA console will be:

/usr/lib/jvm/default-java/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59935,suspend=y,server=n [...] /opt/idea-IU-133.330/lib/idea_rt.jar org.codehaus.groovy.grails.cli.support.GrailsStarter [...] run-app Connected to the target VM, address: '127.0.0.1:59935', transport: 'socket'

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 in BuildConfig.groovy at the run configuration of grails.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:

Listening for transport dt_socket at address: 5005

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 to false. But then you will lose the benefits for forked execution added in Grails 2.3.

查看更多
甜甜的少女心
5楼-- · 2019-01-16 14:51

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:

run-app  --debug-jvm

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.

查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-01-16 14:51

Checkout this blog about Debugging Grails Forked Mode.

查看更多
登录 后发表回答