I'm developing a REST API using Spring Framework.
First I wasn't able to run my application because of the same problem. The port 8080 on my computer is busy. Then I found out that one alternative to solve this problem is creating an application.properties
file under src/main/resources
folder. That's what I made, and set up the server to listen on port 8090. This worked but only for the first time, now I'm getting the same exception whenever I try to run the application for the second time.
Description: The Tomcat connector configured to listen on port 8090 failed to start. The port may already be in use or the connector may be misconfigured. Action: Verify the connector's configuration, identify and stop any process that's listening on port 8090, or configure this application to listen on another port.
As far as I know, this framework makes use of an embedded instance of apache tomcat to deploy every application.
My guess is, the server is not getting restarted the second time I try to run the app, that's why the output says " The port may already be in use or the connector may be misconfigured"
So, a more specific question would be, how can I manage the embedded instance of apache tomcat either manually or programmatically?
I've also modified the port in the application.properties
file twice. It works fine, but again, only for the first time. As you can imagine I cannot do the same each time the app is going to be executed.
Find the process ID (PID) for the port (e.g.: 8080)
On Windows:
netstat -ao | find "8080"
Other Platforms other than windows :
lsof -i:8080
Kill the process ID you found (e.g.: 20712)
On Windows:
Taskkill /PID 20712 /F
Other Platforms other than windows :
kill -9 20712 or kill 20712
On the console, looking at the topmost right side of the dialog you should see a red button kinda like a buzzer. To stop the spring boot application properly you just ran, go ahead and hit this particular "red" button and your problem is solved. Hope this helps!
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