Saturday, May 6, 2017

Remote debugging - Tomcat, Netbeans

To remotely debug your application
  • Add the following to the JAVA_OPTS on the application server.
-Xdebug -Xrunjdwp:transport=dt_socket,address=8800,server=y,suspend=n
  • Restart the application, now you can attach debugger using your IDE. 
  • On Netbeans, go to Debug > Attach Debugger 
  • Choose Debugger as Java Debugger JPDA
  • Connector as SocketAttach 
  • Transport as dt_socket
  • Host as your application server's ip/hostname
  • Port as specified in the debug option in this case 8800. 
  • And click OK and wait for the debugger to attach. 
  • When IDE successfully attaches debugger, "Variables" tab appears on the bottom, and buttons to "Finish Debugger Session" and "Pause" appear on the toolbar.
  • You can add/remove breakpoints by right clicking on the line number on the left and clicking "Toggle Line Breakpoint".
  • You can choose to continue or step over or step into expressions using the buttons on the toolbar that will be enabled when the application is running.


No comments: