Thursday, July 2, 2015

[Tomcat][Debug] Start tomcat in debug mode and remote debug java code in eclipse

More often, we need to debug our applications irrespective of the programming language. I need to debug liferay portlets, hooks etc for troubleshooting issues.

Lets see how we can start our tomcat in debug mode and debug with eclipse. Follow the simple steps.

1. Open catalina.bat in tomcat/bin folder.

2. Search for the line starting with set DEBUG_OPTS=

3. Replace the line with
set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

4. Port number given here is 1044, you can choose any port as per the availability.

5. Now start your tomcat by running catalina.bat. Tomcat logs should print this line at the start
Listening for transport dt_socket at address: 1044

6. In the eclipse, you can do remote debugging, Go to Run > Debug Configurations, under Remote Java Application, create a new node and make sure to change port number for debugging.

All done. Your application is ready for debugging.

Until next time, C ya.


1 comment:

  1. Hi Ravikiran,


    can you please explain What is remote debugg?

    Thanks,
    Naresh.

    ReplyDelete

Note: Only a member of this blog may post a comment.