Friday, March 1, 2013

How to start Apache Tomcat or Jetty Server using maven plugin in remote debugger mode in Ubuntu/Linux

Debugging is one of major requirement of a software debugging process.To fix a bug developer may need to find the exact bug and fix it.Debugging provides efficient way to analyse the variables and execution path of the code.Apache tomcat and Jetty are two of well known server which act as a container for web applications.So debug a web application server need to start in debugger mode.Here simple steps to start tomcat in debugger mode.

In bash console of Ubuntu execute following arguments.

Apache tomcat debugging mode

export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
bin/catalina.sh jpda start

Done!
User can remotely connect through the port 8000 for debug the application!


Jetty debugging mode

Jetty server can start through maven plugin.So in order to enable remote debugging in jetty user can follow the following way.
Just two steps.

step 1
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE - Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

step 2

mvn jetty:run

Done!

Server listen on port 8000 until debugging client connecting to the server.
Simple as that!

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. hi Harsha,
    In case if you have already configured MAVEN_OPTS, this will completely change the variable for that instance.so its better to append the debugging options to the variable as follows.
    export MAVEN_OPTS=$MAVEN_OPTS [options you want to add].

    ReplyDelete
  3. mvn jetty:run -DargLine="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"

    ReplyDelete