Remote Debugging Google App Engine Application on Eclipse

Sometimes it is handy to debug our application source code even when it is executing outside our IDE. This blog will explain how can we remotely debug a web application project developed in Google App Engine on eclipse IDE.

The linux command to start web application on Google App engine development application server is

[sourcecode language=”bash”]
dev_appserver.sh <exploded WAR directory path>
[/sourcecode]

The command runs the application on embedded Jetty server. The problem then reduces to do remote debugging of application with eclipse. We only have to open a debug port on jetty to connect to.

Edit the dev_appserver.sh file to this

[sourcecode language=”bash”]
#!/bin/bash
# Launches the development AppServer
[ -z "${DEBUG}" ] || set -x # trace if $DEBUG env. var. is non-zero
SDK_BIN=`dirname $0 | sed -e "s#^\([^/]\)#${PWD}/\1#"` # sed makes absolute
SDK_LIB=$SDK_BIN/../lib
SDK_CONFIG=$SDK_BIN/../config/sdk
java -ea -cp "$SDK_LIB/appengine-tools-api.jar"
com.google.appengine.tools.KickStart
–jvm_flag=-Xdebug
–jvm_flag=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
com.google.appengine.tools.development.DevAppServerMain $*
[/sourcecode]

This will open a listening port on 1044 which eclipse can connect to using remote debugging. Let us look at how can we configure eclipse IDE to remotely debug our application. In your Eclipse IDE

1. Goto Run->Open Debug Configuration
2. Right click on Remote Java Application option in the left hand menu tree and say new
3. Create a remote java application debug configuration like this

4. Add the sources to the configuration. These should be all your java projects.These are required so that while remotely debugging you can walk through your code

Now, we have configured google app engine development server as well as Eclipse IDE for debugging. Start your application on development server by running the following command at command prompt:
[sourcecode language=”bash”]
./appengine-java-sdk/bin/dev_appserver.sh <exploded war path>
[/sourcecode]
and in eclipse open debug configuration and click on debug button. The debug view would now open at the first breakpoint.

1 thought on “Remote Debugging Google App Engine Application on Eclipse

Leave a Reply

%d bloggers like this: