可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have a problem that I can not set up my application in debug mode with IntelliJ IDE, but run mode is OK.
My OS is Windows 7, IDE is IntelliJ IDEA, web container is Tomcat 6. I have tried for a long time, changed the HTTP port and the JMX port, but it did not work.
When I set up the app in debug mode with IntelliJ, it failed and the event log is:
16:05:35 Error running tomcat: Unable to open debugger port :
java.net.BindException "Address already in use: JVM_Bind".
回答1:
the key to the issue is in debugger port. I was having the same problem, I was killing every process listening on port 8081 (my http port), 1099 (JMX port), tomcat shutdown port, every java.exe, and still nothing.
The thing is this debugger port is different. If you run the application, it will go through the port you have Tomcat configured for, 8080, 8081 or whatever. But if you run it in Debug mode, it goes through a different port.
If you go edit your Tomcat configuration from IntelliJ, the last tab is Startup/Connection. Here go see the configuration for Debug mode, and you'll see its port. Mine was 50473. I changed it to 50472, and everything started working again.
回答2:
For me, IntelliJ Event Log
(right bottom corner) had below logs:
Error running EntitmentTooling-Debug: Cannot run program "/path-to/apache-tomcat-8.5.15/bin/catalina.sh" (in directory "path-to/apache-tomcat-8.5.15/bin"): error=13, Permission denied
Error running EntitmentTooling-Debug: Unable to open debugger port (127.0.0.1:58804): java.net.SocketException "Socket closed"
The command
$ chmod a+x /path-to/apache-tomcat-8.5.15/bin/catalina.sh
to sufficiently change privileges worked for me.
回答3:
If you're on windows you can bypass the socket issue completely by switching to shared memory debugging.
回答4:
This works for me consistently (it happens to me from time to time, when I do things such a restart tomcat when I am running the integration tests, for example)
1) Find the process that has the port 1099 open
sudo netstat -anp | grep tcp | grep 1099
cp6 0 0 :::1099 :::* LISTEN 9857/java
2) kill it
kill 9857
3) Start Tomcat.
回答5:
I had same issue in windows 7 and IntellijIdea 14.
I killed the java processes by going CTRL+ALT+ESc, find java and kill it.
Now Re-Run, the application again it should be fine..
You can also do it with command line or shell(linux), but I found this easier for myself
回答6:
I solved the issue by this way.
- I tried to kill all the java.exe processes but it was useless.
- Then I tried deleting the Tomcat server
- I re-deployed the project and restarted the project and it worked.
See these links for more information:
Delete Tomcat
Add a new Tomcat
回答7:
While debug I got this issue: It worked with
- tried changing my Tomcat http port 8082 to 8083(In debug
configurations on IntelliJ and in Tomcat->conf->server.xml also)
- tried changing JMX port from 1099 to 1009.
- tried changing debug port in Startup/Connection in debug
configurations
- killed all java processes in TaskManager->Processes.
回答8:
I had this exact message.
The reason was that some IDE (I use Eclipse and Intellij) failed to shutdown the tomcat server. Or maybe crashed before it could do so.
The solution was to navigate to C:\...\apache-tomcat-xxx\bin
and run shutdown
.
回答9:
The only thing that worked for me is to go to Task Manager on Windows, and end all the Java processes that is running by right click -> end Task.
回答10:
In Server tab of Tomcat configuration in IntelliJ, change JMX port to another number.
回答11:
I have encountered the same error while using IntelliJ. Since I have started multiple instances of IntelliJ. While starting two instance it started properly. However, when starting another one, it was giving below error.
unable to open debugger port (127.0.0.1:debug-port-number) java.net.socketexception interrupted function call accept failed
There are basically two places you can check your ports related to debugging in IntelliJ
- JMX port - you can find this is
- In Startup/Configuration, there is debug option just click this.
What to Check: If IntelliJ is throwing above error, means issue is any of the above listed ports. To verify this open event log (its available in right corner down) and check the exact message. Event log will have message like below
11:19 PM Error running 'Tomcat-tp': Address localhost:1098 is already in use
11:19 PM Error running 'Tomcat-tp': Unable to open debugger port (127.0.0.1:51787): java.net.SocketException "Interrupted function call: accept failed"
Solution-1
Check the JMX port of current intelliJ which is not starting with the working one and verify if JMX ports are not duplicated within IntelliJ instance or any of the software which is running in your machine is not using this port.
Solution-2
If JMX is not duplicated then verify your debug port, check in all IntelliJ instance and do the changes.
Surely either JMX or Debug port is having issue just use unique JMX and Debug port and it will work.
Hope this will help someone.
回答12:
It happens occasionally that when I restart my computer, everything is OK. Perhaps there is a port conflict.
Restart the computer works because instances of Java or Tomcat are killed during the restart. You can also consider killing the specific processes from Task Manager
This also happens if there is an issue in the context.xml file. In my case, I had accidentally changed the context value.
回答13:
I have the same issue,because my computer's DNS miss 127.0.0.1 localhost.
When I add 127.0.0.1 localhost to my host file,it become ok.
回答14:
There are various reasons for this.
- There might be the problem with debugger port---Please change it to resolve( answered by T.M )
- There might be some issue with intellij cache --Invalidate cache and restart will solve it ( answered by feng smith )
- There might be problem with any other Port, like JMX, AJP --- Please change these port numbers as well.
I wanted to add this as comment but not enough rep
回答15:
None of above methods worked in my case i.e. changing port number in run configuration, machine restart, invalidate cache in IntelliJ, killing process shown in netstat (nestat -anob | findstr <port-number>
and then tskill <pid>
). The only thing that finally helped was starting and shutting down tomcat manually via startup.bat
and shutdown.bat
(you should use correspondig .sh
files on linux and macOS).
回答16:
Change debug port of your server configured in the Intelli J.
It will be fixed.
回答17:
All the other solutions unfortunately did not work.
This is what worked for me . I simply changed the debugger port to some other port number.
Intelij-> preferences->Build, execution, deployment ->Debugger-> Built in server->port(change value )
回答18:
In my case, there was a problem in server.xml for Tomcat/conf folder where I had extra comment tags under another comment tag. So I think, since there was some problem in server.xml, it was not able to start Tomcat. And moreover it copies the tomcat folder from your installation directory to C:\Users\username.IntelliJIdea2017.2\system\tomcat\Tomcat_service
回答19:
This happens when you have application running on the same port number. One way to do this by killing the process forcefully. Open command prompt as an admin. Run command 'taskkill /IM "java.exe" /F'. This worked for me in Windows. Let me know if this works.
回答20:
- Check "Run" configuration to see which port it is using (
8081
).
- Find all the other processes using that port
lsof -t -i :8081
- Kill the processes on that port.
kill PROCESS_ID
- Run Tomcat in Debug mode.
In my case, I wasted so much time on changing debugger port but it was not the issue. Since tomcat was not able to run on the port I chose in Run configuration, I was not able to debug my service.
回答21:
In my case I had another project open in IntelliJ, and had Tomcat running in debug mode in that project.
Stopping that instance of Tomcat resolved the issue.
回答22:
My assumption that this exception usually occurs when Tomcat is improperly closed and still holding the ports.
Usually it is enough to kill any process listening to 1099 port. For Window 10:
netstat -aon | find "1099"
taskkill /F /PID $processId
回答23:
Probably you get the same error message if the standalone.xml in your standalone/configuration folder cannot be found. At least I have the same error when using a WildFly 14.0.1:
回答24:
There are multiple solution for the same.
- Either we may close the IDE (e.g. IntellJ)
- Find t
IND00123:bin devbratanand$ lsof -i:30303
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
idea 437 devbratanand 56u IPv4 0xb2720e580a7d6483 0t0 TCP 10.17.130.41:55222->vmqp-cms-pan-app1.emea.akqa.local:30303 (ESTABLISHED)
IND00123:bin devbratanand$ kill -9 437
回答25:
try chmod a+x /path/to/tomcat/bin/catalina.sh if you run it in intelliJ