Monday, February 21, 2011

Maven war overlay and debugging

I'm currently working on a project which uses the maven war overlay feature. In such condition, I didn't succeed to start my a Tomcat instance from Eclipse WTP. That's because the war is built to late in the maven process and the Maven integration with WTP never calls the appropriate building step. Thus, I decided to start my server from the command line. With 'war overlay', I need to do :

mvn tomcat:run-war

But, what about debugging? Here I found two solutions.

Solution 1 : the standard mode

Just use :

mvnDebug tomcat:run-war

But it's a pre-configured solution and you should want to precise some specific options according to your environment.

Solution 2 : customize your debugging options

This is very simple.
  • Ensure that you correctly declared your JAVA_HOME
  • Set the debugging options which will be used by the JVM

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

Then, just start your server with mvn tomcat:run-war