Eclipse closed automatically - java

When I was running my project on 8080 port immediately the eclipse closed automatically and the port is still running with the project, I reponed and I can't run the project on 8080 port anymore.
In Mac OS.

[sudo] lsof -ti:8080 | xargs kill should pull up the PID binding to 8080 and kill it

Related

Facing issue with Tomcat execution in eclipse

I tried uninstalling and reinstalling tomcat after removing the server instance from the eclipse environment. I spent so much time yet there is no use. This is the error I keep receiving.
Error in the eclipse environment.
It says that the port 8080 required by Tomcat is in use. But in port 8080 only tomcat is running. I am attaching a screenshot for the same.Ports in Resource Manager.
Please help me resolve this issue, Thanks in advance!!!.
netstat -ano | findstr :
for example, use the below command in the terminal or cmd
netstat -ano | findstr :8080
find the process id
and then use
taskkill /PID /F
to kill the task.

Web server failed to start. Port 8080 was already in use

I am trying to develope a webapp using spring boot in STS. While running my app i am getting
Description:
Web server failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that's listening on port 8080 or
configure this application to listen on another port.
I have tried to close the application for port 8080. I found the PID for the port and terminated it using
taskkill /F /PID pidname
I restarted the STS and tried to run again but its throwing the same error.
If port is acquired by some OS thread, it would be a bit tricky to stop it. Although it's not always great solution, but if you still want to continue with your development without any issue you can use this alternative solution (as you are in development environment).
Here is another thing you can use. You can replace the default port for Spring Boot server to some other port number.
For server port the property is server.port.
If you are using application.properties file:
server.port=8081
It will start server on port 8081.
Similarly, you can do the same if using an application.yml file:
server:
port : 8081
Each file is loaded by Spring Boot if placed in the src/main/resources directory of a Maven application.
Your only other option (beside making port 8080 available or using another port for spring boot) is running the application in docker:
Create a Dockerfile in your application directory
FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Run in terminal
sudo docker build -t spring-app . && docker run -d -p 8080:8080 -t springapp
(This assumes you have docker installed, please install it if you don’t have it)

Shell script to validate if my tomcat is running or not - uniquely identify

I see many shell scripts to check process if that is running we proceed further.
But there is scenario like below or if we have multiple tomcat running on single host, how do we identify if our process running?
e.g if I go to path /opt/alfresco/tomcat/bin and execute command
ps -ef | grep tomcat
It will give me output (even tomcat is not running)
[alfresco#host030 bin]$ ps -ef |grep tomcat
alfresco 12090 11302 0 22:57 pts/0 00:00:00 grep tomcat
[alfresco#host030 bin]$
So if I am using alfresco tomcat and I need to validate if my tomcat process actually started and running, how do I validate?
Also to differentiate between any java and tomcat running, HOW ?
You can try with the below script. Do grep for the listening port, use your port number.
JAVA_HOME=/usr/java/default
SHUTDOWN_PORT=`netstat -vatn|grep LISTEN|grep 8005|wc -l`
export JAVA_HOME=$JAVA_HOME
if [ $SHUTDOWN_PORT -ne 0 ]; then
echo 'Alfresco is running'
else
echo "Alfresco is not running"
To start it you can use
ALF_HOME=/www/web/dev1/alfresco
$ALF_SCRIPT start
If your tomcat is running as a service you can run service tomcat status.
If its not running as service its recommended to do it..
Read this how to do it: https://www.linux.com/learn/managing-linux-daemons-init-scripts

how to stop all ports in apache tomcat

While developing a web application using Apache Tomacat and Eclipse frequently I get this message
Several ports (7354, 6544, 9999) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
I know that this ports are in use, but I don't if I stop all those servers also why get the same message. My question is - Is there any way to stop all ports at once in using Eclipse or Windows 7 ?
you can use the lsof in combination with awk. do the following:
lsof -i :<portnumber> | awk '{print "kill -9 "$2}' | sh
if you want to know only the processId from the port, use:
lsof -i :<portnumber> | awk '{print $2}'
btw: i have this problem sometimes too. If you're using eclipse check in the debug view if there is still a thread of the tomcat running. if so, stop them :)
Otherwise restart eclipse.
Have you tried the following?
ps -ef | grep <port number>
kill -9 <process id>

Changing port when running Jetty using jetty-runner

I'm executing the following command line:
java -jar C:\WorkArea\jetty-runner.jar c:\name.war --port 9090
I'm expecting it to run on port 9090 but it keeps on running using port 8080 which is the default.
What am I missing?
When running through eclipse itself, it is using 8888 so it's not taking this info from there, where/how else can I control the port?
Thanks
The documentation of the Jetty Runner suggests that the port option should be passed before the WAR file:
java -jar C:\WorkArea\jetty-runner.jar --port 9090 c:\name.war

Categories

Resources