Home > Maven > Debugging maven web application with eclipse

Debugging maven web application with eclipse

March 3, 2011


Recently I started a new JEE project using Maven2 as build tool, choice done du to the different services that it offers for project with a lot of modules and complex dependency ….
One of the problems that I faced is debugging web layer with respect to the directory structure of the default web archtype.

Here is the best method I found to solve this need:

I suppose that you already created a maven2 web project if not see :

To run http web server I use jetty plugin by simply adding the jetty plugin to the pom.xml

In order to validate this phase it’s possible de run the web app from the command line: mvn jetty:run and wating for maven to download the plugin and if successful running the application.

After that It’s time to configure eclipse for debugging the web app by selecting the Run > Debug … from the menu
# Set Main Class to “org.codehaus.classworlds.Launcher”

Go to the argument tab:
# Set Program arguments to “jetty6:run”
# Set VM arguments to “-Xmx512M -Dclassworlds.conf=[MAVEN_HOME]/bin/m2.conf -Dmaven.home=[MAVEN_HOME]”
(Replace MAVEN_HOME with the location of maven on your system)

Go to the classpath tab:
# remove the application from the user entries
# add the “[MAVEN_HOME]/core/boot/classworlds-1.1.jar” to the user entries

Go to the source tab:
# add the current project to debug

Now you can start debugging your application like you do it always

It is very interesting to set the –o option to the maven command in order to accelerate the fix/debug process.


Categories: Maven
%d bloggers like this: