Pages

Wednesday, November 7, 2012

Remote Debug on Tomcat Server with ANT/Maven Deployment Tool

Hi Guys,

Here I am going to show you the steps to debug web application which are developed using ANT or Maven Deployment Tools.
When ANT or Maven are used to deploy web applications on tomcat server(v.6.0 or 7.0), at that time the war files are deployed automatically.
If DEBUGGING is required then we have to do it remotely. For that we have to do some configurations:

For Windows Users:-

1. Open catalina.bat (PATH: tomcat\bin\catalina.bat) file.
2. find “DEBUG_OPTS=” and modify this property.

set DEBUG_OPTS= -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888

3. Now, Come to Eclipse. And follow this steps:

a) Open debug perspective[Windows->open perspective ->Other->Debug]
b) Run-> Open "Debug" Dialog -> Remote Java Application -> New configuration ->
c) Select the project -> Enter the port number as debug port in the Catalina.bat (8888)

4. Restart the server.
5. Put breakpoints in files.
6. Start Debug from Eclipse.

Now, you are done..

For Linux/ Ubuntu Users:-


1. Go to tomcat/bin/catalina.sh

2. find below line

JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"

3. add this line below it

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888"

So now your file looks like this

# Set juli LogManager if it is present
if [ -r "$CATALINA_BASE"/conf/logging.properties ]; then
  JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
  JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888"
  LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
fi

Save this file

4. Goto Eclipse-->Debug configuration
5. select java remote application->create new configuration
6. source tab - select your project
7. connect tab - add port number 8888
8. restart sever
9. put break points
10. Start Debug from Eclipse.


That's it..
If you are Maven user, then do "Maven Clean" and "Maven Install" and then start your debug configuration.