Reputation: 9761
I'd like to understand how remote debug works exactly. Do i need to have my application deployed on tomcat for it to work? More specifically, given that i have the source code on my machine, does the client debugger on IntelliJ, transfer the code instruction to the server debugger on the Remote machine, or the code is already deployed on that machine.
From all the example i saw on the JDA, an application must be started with the required option on the remote machine, such that a client debugger (Front end) can connect to the Debugger back end on that machine.
But it is not clear to me how to make it work with Containers like tomact. From the example i read, it seems the application in that case would only be tomcat and the instruction from the source code transfered by the wire. Indeed, i don't see any steps to deploy the app.
Please can someone explain it a little.
Upvotes: 0
Views: 675
Reputation: 3779
When you debug an application deployed inside a tomcat container, you must have your application deployed remotely. Remote debugging debugs the remote application (that resides inside the tomcat container). The source code that you see in intellij is not transferred to the server during debug.
You may try a little experiment: add some lines to your source code and put breakpoints on them, then start a remote debug session without redeploying. Because you'll be out of sync between source code and deployed code, you'll see that breakpoints on the new code lines are marked with a red 'x' by intellij - this is because the debugger cannot find those lines (by line number) on the server.
Debugging may actually work and stop on breakpoints, even when the source code you have in intellij is different than the code on the remote server, as long as breakpoints are in classes with same names on both. However the code that is actually run is the code that is on the server.
As a side note, you may change code inside intellij during a debug session and have the change take effect in the server immediately (until end of debug session). To do this, compile the changed class (ctrl+F9 in intllij) while the debug session is waiting on a breakpoint. This invokes the HotSwap mecahnism.
Upvotes: 2
Reputation: 26713
Tomcat remote debugging is as easy as starting Tomcat in the following way:
/some/path$ catalina.sh jpda start
This will start Tomcat with remote debugging enabled on default port, 8000. Many other things, including how to change this port, are explained in the FAQ.
Upvotes: 1