środa, 26 stycznia 2011

How to debug applications run by mvn jetty / tomcat in netbeans?

My mates asked me many times about this, so this post is just short information.

For mvn jetty, just add line like this:

set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=4000 -Xmx512m -Xms256m -XX:MaxPermSize=192m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC

in your $MVN_HOME/bin/mvn.bat file. Then just attach debugger from netbeans: Debug->Attach Debugger where options are:

Debugger: Java Debugger (JPDA)
Connector: SocketAttach(Attaches by socketto other VMs)
Transport: dt_socket
Host: your_host_name
Port: 4000 ( port is set in mvn.bat line which we added)

You can easily debug applications which are working on local tomcat. Its done by similar to maven configuration. Add line:

set JAVA_OPTS=-server -Xmx1024m -Xms1024m -Xdebug -Xrunjdwp:transport=dt_socket,address=7779,server=y,suspend=n -Dfile.encoding=ISO-8859-2 -XX:MaxPermSize=192m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC

in your $TOMCAT_HOME/bin/catalina.bat file. Debugger configuration in netbeans is same like above.

Be aware, that options set by these lines are specific to our development environment, change them if needed.

Happy debuggging : )