18

Jul

2008

Debugging Tomcat as an External Tool from Eclipse

You can also configure Eclipse to be able to start and stop tomcat as a program (this approach also seems to work well on Windows). To configure Eclipse to be able to start and stop tomcat:

  1. If you have not already done so, set a breakpoint somewhere in your code (preferably something not associated with startup) by left-clicking to the left of a line of code.
  2. Under the “Run” menu, select the “External Tools” sub-menu, then the “External Tools” heading.
  3. On the dialog that appears, single-click the “Program” heading, then click the “New” icon (a page with a plus on it).
  4. Change the Name to something meaningful, like “Sakai 2.4”.
  5. Under “Location”, enter full path and filename for your catalina script (catalina.sh on UNIX, catalina.bat on Windows).
  6. Under “Working Directory” to the location of your tomcat installation.
    Under “Arguments”, enter “jpda start”.
  7. If you use “jdpa run” rather than “jpda start”, Tomcat will not open a new window to start in and will instead give you all it’s standard err and standard out in the Eclipse console window. This is usefull for Windows developers who don’t like to read console output from a DOS window.
  8. Go to the “Environment” tab. Click “New” and enter “JPDA_ADDRESS” as the name and “8000” as the value, then hit “OK”.
  9. Click “New” again and enter “JPDA_TRANSPORT” as the name and “dt_socket” as the value, then hit “OK”.
  10. Click “New” again and enter “JAVA_OPTS” as the name and “-server -XX:+UseParallelGC -Xmx768m -XX:MaxPermSize=160m -Djava.awt.headless=true” as the value, then hit “OK”.
  11. Open the “Common” tab. Check the box marked “External Tools” in the panel marked “Display in favorites menu”.
  12. Check the box marked “Launch in background”.
  13. Hit “Apply” to save your changes.
  14. Hit “Run” to test your configuration.
  15. Once Sakai finishes starting up, open your browser and work with Sakai until you reach your breakpoint. You should be directed into Eclipse where you will see the line of code with your breakpoint, a list of variables, etc., etc.

NOTE:

tomcat will start when you run it as an external tool, but you will probably not see console output. You’ll need to open another window that contains the contents of catalina.out to keep track of the startup or use jpda run

Comments are closed.