I have an application that I deployed in tomcat. Later I configured the code as a project in Eclipse. I want to connect to the tomcat via eclipse and debug the application. Trying to setup a remote debug connection is throwing up errors. Is there any entry that I need to add somewhere in tomcat?
Go to the eclipse menu and select Run->Debug Configuration; it opens Debug Configuration setup. On the Debug configuration window, create a new “Remote Java Application” configuration. Select the project to be debugged and give it a Name. Select connection type, Socket Attach, or Socket Listen.
To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.
By default tomcat running port is 8080. So for the debugger, I will allocate port 8081. For that, you can select any port except tomcat running port or any other allocated ports in your localhost for other running servers.
First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the start
command, and change it to jpda start
. This will cause Tomcat to start in debugging mode listening on port 8000
.
Next, to connect to this process via Eclipse, select the Run
menu and choose Debug Configurations...
. In the pane on the left, choose Remote Java Application
and click the New launch configuration
button above the list. The important settings to note are the Host
and Port
fields. The host value must match the hostname of the Tomcat process, and the port should be 8000
. You also might need to add entries on the Source
tab to ensure that all of the source code is available to step through.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With