views:

130

answers:

4

I've not built a Java web application before, but I have it complete enough to test and Maven is building my WAR file just fine. It is a multi-module Maven project and the dependent modules all have their JAR files in the WEB-INF/lib directory of the WAR.

So everything seems fine, but how to debug? I know how to (from the command line) run the WAR in Tomcat on my machine. I also think I know how to set up and run the Maven Jetty plugin from the command line as well. But how best to debug...with all the break points and variable inspection I love with Eclipse?

Is there some kind of launch configuration I should create, or do I attach the debugger remotely? Is there something in Eclipse that can help...like a plugin?

A: 

I don't know much detail but try this link http://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging

Reddy
+2  A: 

To enable debugging through eclipse :

I pass following to Tomcat startup:

-Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=9999,suspend=n

Then through Eclipse do Remote Debug.

  • Goto Debug Menu > Debug Configuration

  • Scroll Down to Select Remote Java Application

  • rt click to create new
    configuration
  • Select connection type as Standard (Socket Attach) and add hostname and port.

To start debugging simple open it when server is running.---

YoK
and select the project[source code] as well
Rakesh Juyal
+1  A: 

Is there some kind of launch configuration I should create, or do I attach the debugger remotely? Is there something in Eclipse that can help...like a plugin?

With m2eclipse (and the Maven Integration for WTP that you install from the Extras), you could use the WTP and start your app in debug mode.

As an alternative, you could connect a remote debugger to a Jetty. See Debugging with the Maven Jetty Plugin in Eclipse.

Pascal Thivent
I have m2eclipse installed. How to I used WTP to start my app in debug mode?
HDave
+2  A: 

If you run your WAR with tomcat/jetty plugin pass debug options to the Maven:

export MAVEN_OPTS="-Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" mvn tomcat:run

If you run your WAR using the regular Tomcat, just run it with JPDA (debugger) support enabled:

$TOMCAT_HOME/bin/catalina.sh jpda start

Default port for Tomcat 6 JPDA is 8000.

Now connect with the Eclipse (Debug -> Remote Java Application) to the port 8000 and enjoy your fine debugging session.

Henryk Konsek