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

dev_appserver.sh <exploded WAR directory path>

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

#!/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 $*

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:

./appengine-java-sdk/bin/dev_appserver.sh <exploded war path>

and in eclipse open debug configuration and click on debug button. The debug view would now open at the first breakpoint.

This entry was posted in Java and tagged , , , . Bookmark the permalink.

One Response to Remote Debugging Google App Engine Application on Eclipse

  1. roshandawrani says:

    Thanks for the post. Just what I was looking for..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s