/Apache-Tomcat-9-Free-Port

:cat: Free the Apache Tomcat server port used by other LISTENING PORT (e.g 8080). Saved time instead of resetting the server / IDE

Primary LanguageJava

Apache-Tomcat-9-Free-Port

When using Tomcat 9, user usually forgot to stop the server before shutting down IDE(eg Eclipse) this will create a problem when will try to run it again on other trials

This application will Free the Apache Tomcat server port used by other LISTENING PORT (e.g 8080). Saved time instead of resetting the server / IDE / kill the port manually on CMD.

If you encounter the problems "Several ports (8005, 8080, 8009) required by Tomcat Server at localhost are already in use" in Eclipse when working with JSP, servlet::

Several ports (8005, 8080, 8009) required by Tomcat v9.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).

image

or when using the cargo:run maven build with cargo-maven2-plugins

[ERROR] Starting container [org.codehaus.cargo.container.tomcat.Tomcat9xEmbeddedLocalContainer@46349b95] failed
org.codehaus.cargo.container.ContainerException: Port number 8080 (defined with the property cargo.servlet.port) is in use. 
Please free it on the system or set it to a different port in the container configuration.

image

▶️ Demo

Download the For Users folder and run the Tomcat9FreePort.exe file WITH ADMINISTRATOR

image

image

Note: always keep the Tomcat9FreePort.exe file and Tomcat9FreePort.jar file in the same folder.

You will be ask to enter the Tomcat server port number that you used to install Tomcat in the first place, the default is 8080. User using cargo-maven2-plugins will have the default as 8080 so click OK.

image

The Tomcat9FreePort.exe will scan (through cmd) to find the LISTENING PORT USING the port number that you provided and have you confirmed to Free this LISTENING PORT

image

After you confirm to kill the LISTENING PORT, there will be a confirmation box

image

🔵 Source Code

The Project Code can be access here

Build With

🔵 More Resources

📄 Setting up Tomcat Sever using cargo-maven2-plugin on Eclipse.

Insert the following plugin into your in pom.xml file of your Maven Project

<plugin>
   			<groupId>org.codehaus.cargo</groupId>
   			<artifactId>cargo-maven2-plugin</artifactId>
   			<version>1.6.7</version>
   			<configuration>
   				<container>
   					<containerId>tomcat9x</containerId>
   					<type>embedded</type>
   				</container>
   			</configuration>	
   		</plugin>

Right click on the pom.xml file and RunAs --> Maven Build... --> In the Edit Configuration Windows, type Cargo:Run in the Goals Box

image

Click Run and it will set up the Tomcat Sever 9 with default Port as 8080

image

You can test the server through http://localhost:8080/project-name/file-name.html

Author

Long Phan