Monday 5 July 2010

Getting eclipse to connect to a running tomcat

Firstly tomcat needs to set up to allow a debug connection.

These instructions are for windows - sorry.

  • Go to the tomcat/bin directory and run tomcat6w.exe
  • Click on the java tab
  • To connect on port 8002 add the line:
    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002
  • And start tomcat normally


Now go to eclipse.

  • Go the Debug perspective
  • Click on the 'bug' arrow and select 'Debug Configurations'
  • Double click 'Remote Java Application'
  • Give it a name EG 'tomcat'
  • Select the project
  • Select the server if it is not localhost (the default)
  • Select the port that you used above eg 8002
  • Click on the 'debug' button and you are now debugging the tomcat session.

If you want to save that config to use again do the following

  • Click on the 'bug' arrow and select 'organise Favourites'
  • Select 'Add'
  • Search down for the name of the debug session and tick the box
  • Select OK.