IntelliJ IDEA Debugger isn't working on a Grails Project

后端 未结 11 1698
孤独总比滥情好
孤独总比滥情好 2020-12-07 22:45

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 brea

相关标签:
11条回答
  • 2020-12-07 23:24

    Try this:

    In idea choose Edit configurations from list next to 'run' button. Then add Remote, choose your name and left default remote configuration settings. (port 5005 etc)

    Run your app from console by using

    grails run-app --debug-fork
    

    In idea, choose your configuration from list and hit debug button when console display info:

    Listening for transport dt_socket at address: 5005
    
    0 讨论(0)
  • 2020-12-07 23:26

    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.

    0 讨论(0)
  • 2020-12-07 23:28

    I tested with intellij latest with Grails 2.3.4 on Mac Os x Lion.

    Then I tried Igors's advice and it is working without forked mode.

    grails.project.fork = [
        test: false,
        run: false
    ]
    

    Please check for detail grails documentation

    if you want to debug forked mode you should check following blog post explainsvery well.

    http://blog.jdriven.com/2013/12/grails-goodness-debugging-app-forked-mode/

    0 讨论(0)
  • 2020-12-07 23:36

    I have tried all mentioned here without success. The only helpful information is here.

    In essence you should disable forked execution by adding the following to grails-app/conf/BuildConfig.groovy:

    grails.project.fork = [
        test: false,
        run: false
    ]
    

    Now debugging is available in IntelliJ IDEA Ultimate Edition v.12.1.6 just by ordinary Debug without Remote debugging. Tested on Grails 2.3.1, Java 1.7.0_45, Windows 7 64-bit.

    0 讨论(0)
  • 2020-12-07 23:36

    Checkout this blog about Debugging Grails Forked Mode.

    0 讨论(0)
  • 2020-12-07 23:39

    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/

    0 讨论(0)
提交回复
热议问题