Debugging remote Tomcat from Eclipse
I recently set up a new Project using Maven 2. Sadly, while facilitating the Project setup, this means that I couldn’t get all the free configuration I could have had by simply clicking through the Eclipse Wizard for Dynamic Web Projects, namely the ability to run the Tomcat container right inside Eclipse, with automagic reloading, etc…
Luckily I found this post by Narendra Naidu which explains the details on how to start Tomcat in the JPDA debugging mode, and how to attach Eclipse to it:
- Start Tomcat in JPDA debug mode. For this, set up two variables in the environment as follows:
- The first variable is: set JPDA_TRANSPORT=dt_socket (This tells the VM that the debugger would talk to the VM on Tcp sockets)
- The second variable is: set JPDA_ADDRESS=8000 (This tells the VM the port on which it should listen for debugger connections)
- Go to the command prompt and run the ‘Catalina.bat’ batch file present in {TomcatHome}bin. On the command prompt pass the following argument: catalina jdpa start
- Go to Eclipse and open the Debug window. Create a new configuration under ‘Remote Java Application’ . Make sure ‘Connection Type’ is Socket and port is 8000
- Navigate the webapplication thru web browser and see your Eclipse stop at breakpoints.
