Thursday, October 29, 2009

Remotely debugging Grails/SmartGWT from Eclipse


  • Edit %HOMEPATH%\.grails\%GRAILS_VERSION%\projects\%PROJECT_NAME%\plugins\gwt-%GRAILS_GWT_PLUGIN_VERSION%\scripts\RunGwtClient.groovy such that:

gwtRun('com.google.gwt.dev.GWTShell') {
        // Hosted mode requires a special JVM argument on Mac OS X.
if (antProject.properties.'os.name' == 'Mac OS X') {
jvmarg(value: '-XstartOnFirstThread')
}

arg(value: "-out")
arg(value: gwtOutputPath)
arg(value: "http://${targetServer}/${grailsAppName}")
}

becomes:

gwtRun('com.google.gwt.dev.GWTShell') {
        // Hosted mode requires a special JVM argument on Mac OS X.
if (antProject.properties.'os.name' == 'Mac OS X') {
jvmarg(value: '-XstartOnFirstThread')
}

jvmarg(value: '-Xdebug')
jvmarg(value: '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044')

arg(value: "-out")
arg(value: gwtOutputPath)
arg(value: "http://${targetServer}/${grailsAppName}")
}

  • Import your Grails/GWT project into Eclipse and create a Debug launch config (as blogged here)

  • Launch the GWTShell in debug-able mode with: grails run-gwt-client

  • Now, attach the Eclipse debugger to the GWTShell (as blogged here) and manipulate your Grails/SmartGWT application with the GWTBrowser (only) hitting Eclipse'd breakpoints as you go.

Of course, every time you run that Grails target i.e. run-gwt-client you'll be launching in debug-able mode; a smoother way to flag your intention to debug awaits your Groovy skills.

No comments: