How I can avoid error with debug jsp at intellij?

I try doing debug jsp at intellij.
But then I hit the debug button I receive error:

"Error running events.jsp: Unable to open debugger port : "socket closed"

How can I avoid from that?


Is your server local or remote? What type of debug configuration are you using, local or remote?  For remote debugging, you need to make sure the JVM arguments, specified in the "Command line arguments fro running remote JVM", are passed into the remote server on start-up. And the server must be started before you launch the debug configuration in IDEA. Take a look at the "Run/Debug Configuration: Remote" and "Run/Debug Configuration: Tomcat" (or whatever your server is)  in Help > Reference > Dialogs > Run/Debug Configurations. If you are still having problems, please post screenshots or the debug configuration you are using.


Thanks for answer.

My server is local. It installed on my computer.

I did local tomcat configuration. And then I push debug I get error. I attached screenshots.


Your configurations look ok. The error in the screenshot ("port already in use")  is a bit different than the original error you posted. But both are about problems with the debug port.

Make sure you do not have any other tomcat run/debug configurations running. Stop any and all on both the run tool window and the debug tool window. Once all are closed, try launching the "tomcat local" configuration as a debug execution. (Just to make sure there is no confusion, for debugging, you just launch the configuration in debug. Running via debug also starts the server; it's not just to attach the debugger. I've seen people misunderstand that and launch the tomcat server under run, then try to "launch" the debug.) If you still have the port in use issue, it may mean a tomcat is stuck running in the background. Exit IDEA, open your process manager and make sure no java apps are running, then restart IDEA. Then launch the debug configuration. If you still have issues, try another JMX port (on the "Server" tab) for the debug port.

Let us know how that goes.


Thanks for answer.

Today I turned on the computer, then launched idea, select "local tomcat" configuaration, started debug(shift + f9) and got debugging.

It's working now. Maybe, in the future such mistake will be again.

Can I ask you the question? What the difference between buttons: "debug local tomcat (shift + f9), debug(Atl+shift+f9) and rerun local tomcat(ctrl + f5)?


virtus wrote:

Can I ask you the question? What the difference between buttons: "debug local tomcat (shift + f9), debug(Atl+shift+f9) and rerun local tomcat(ctrl + f5)?

Shift+F9 will run, in debug, whatever option is selected in the run/debug drop down list in the top menu area (to the left of the run/debug buttons).

Alt+Shift+F9 will open a quick list pop-up window so you can select what debug configuration you wish to run. This is very useful when you have numerous run/debug configurations. It does not change the selected run/debug configuration in the run/debug drop down at the top. So it is a quick way to run an alternate run/debug configuration. Via the side menu (using right arrow to open), you can also quickly get to the edit option (and other run options) to edit a configuration. The primary advantage of the quick list is being able to select a run/debug configuration without having to use the mouse. IDEA has a strong focus on being able to do things without the need to use a mouse since it allows you to work faster and more efficiently.

Use F10 in the above shortcuts to access the same features but as a Run rather than as a Debug.

Ctrl+F5 (and its corresponding button) is an action of the debug (and run) tool window. It simply allows an easy way to rerun/re-debug a run/debug configuration when the run/debug window has focus. It's just another way of working. Different people have different personal "workflow" in how they do their development. So this is just another option. You can pin executed run/debug configurations in their respective tool windows and use Alt+Left-Arrow and Alt+Right-Arrow to switch between them (when the tool window has focus). Then you can use Ctrl+F5 to run that run/debug configuration after switching to the appropriate tab. For some this is an easier way to work, especially if you need to switch between different run/debug configurations. For example, you could pin a unit test run and a server/application run to the run (or debug) tool window. As you work, you can modify code, put focus on the run (or debug) tool window via Alt+4 (Or Alt+5), use Alt+Arrow to switch to the unit test pinned run tab, use Ctrl+F5 to re-run it, then switch to the server/application tab (via Alt+Arrow) and rerun your server/application via Ctrl+F5. Once down, you repeat the whole process and add/change more code. You could of course also do this with the Alt+Shift+F9 quick list. It's just a matter of personal preference.


Thanks a lot for such detailed answer! :)


Please sign in to leave a comment.