Thursday, July 7, 2011

Starting Tomcat with jpda to do real time Debugging of Web application

If you are planning to debug a tomcat application using Eclipses's remote debugger you need to start tomcat with JPDA... In Ubuntu the tomcat startup does not have a jpda command line parameter so you need to do a little bit of change to your startup scripts to enable it..

Here is all you need to do:

1. Add following lines into /etc/init.d/tomcat6 :

if [ "$2" = "jpda" ]
then
    JPDA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
fi
CATALINA_OPTS="$JPDA_OPTS"


2. Edit the below line in /etc/init.d/tomcat6

$DAEMON -user "$TOMCAT6_USER" -cp "$JSVC_CLASSPATH" \
                    -outfile SYSLOG -errfile SYSLOG \
                    -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"

to become 

$DAEMON -user "$TOMCAT6_USER" -cp "$JSVC_CLASSPATH" \
                    -outfile SYSLOG -errfile SYSLOG \
                       $CATALINA_OPTS \
                    -pidfile "$CATALINA_PID" $JAVA_OPTS "$BOOTSTRAP_CLASS"

3.  Start tomcat now with jpda as a command line parameter..

sudo service tomcat6 start jpda

No comments:

Post a Comment