...
The short answer is to add the following options when the JVM is started:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
There are a number of ways you can do this depending on how you normally start Tomcat:
- If you are using shell scripts to start Tomcat, start it with the following command:
catalina jpda start
The above mentioned options can be provided by setting certain environment variables, e.g.JPDA_ADDRESS=8000
andJPDA_TRANSPORT=dt_socket
. See comments at the top ofcatalina.sh
or.bat
file for details. - If you run Tomcat using service wrapper, add the above JVM options before any other JVM options. Check the documentation for the service to determine how to set JVM options.Set environment variables
JPDA_ADDRESS=8000
andJPDA_TRANSPORT=dt_socket
and then start tomcat usingcatalina jpda start
. - If you start Tomcat from within an IDE, check the documentation for the IDE to determine how to set the required JVM options.
...
This answer assumes that you have a project set up with all of the fixings and have some idea of what you 're are doing in this respect. If not then thats that is really outside the scope of this topic and more in the scope of you needing need to go to eclipse.org and read up on how to use your ideIDE, and maybe practice a little bit before you come back to this. We are also going to assume that you have some idea of what a debugger is and how to use one.
- Make sure that Tomcat is started in remote debugging mode as described above and that your app is deployed
...
- .
- Make sure that you have the sources
...
- for the code that you are trying to debug in your IDE. For the libraries and for Tomcat itself you can "attach" the sources to the jar files: open a class file and then click "Attach Source..." button.
- If you have a servlet or something, set a breakpoint where
...
- it is sure to hit on the next request.
- Go to "Run->Debug Configurations...". Click on "Remote Java Applications", then click "New". Type in the title
...
- .
...
- Note that port 8000 from the Tomcat instructions. Save and run.
- Eclipse will connect to the
...
- JVM that Tomcat is running under. Wow, that was easy!
Now go type the url to submit to your servlet or whatever in your browser. Boom you hit the breakpoint right? Have fun!
...
Monitoring interval for application reloading is controlled by the backgroundProcessorDelay
property on Context
element or on its parent containers: Host
and Engine
. See Tomcat Configuration Reference for details. By default there is a single backgroung background processing thread that is run by Engine. See its configuration for the default delay value.
...