Java Topics

Saturday, February 26, 2022

Tomcat

Tomcat is an web server which is used to run our web applications. Tomcat server is an open source/free software and anyone can download from the official Tomcat website from the Browser.

Step by Step guide to setup tomcat server in our local system:

1. Download Tomcat server from below official website

    https://tomcat.apache.org/

  Click on Tomcat9.0 from left side ----> then select "32-bit/64 bit Windows Service Installer(pgp,sha512)" as below.

      


2. Once the file is downlaoded, extract the "apache-tomcat-9.0.59-windows-x64.zip" file in your local system.

3. Goto bin folder-----> open startup.bat.

        


4. You can see below console will open that the tomcat server has been started.

       


5. Open the below URL in browser to verify whether tomcat server is up and running fine. If you see below window, that your tomcat server is running fine.

    


6. To stop Tomcat server, click on shutdown.bat under bin folder in your local system.

     



7. Suppose, if you want to test your code changes with the new .war file, you can place that .war file under "webapps" folder and run the startup.bat script and test your changes.

Below are the different issues we may experience while setting up tomcat server and find the solutions below to fix the issues.

1. Once you run startup.bat file, the window/console will open for 1 0r 2 secs and closes immediately.

   Solution: You need to add environment variables as below.

     Right click on This PC---->select Properties -----> click on Advanced System settings ----> Go to Environment Variables. Set the varibales as shown in below screenshots.

       i. First set  "CATALINA_HOME" under "User varibales" as below and copy the path/value before bin folder.

        


        ii. Then, add "JAVA_HOME" path under "System Variables" as below. 

                


      iii. Set the jdk path (copy the jdk path till bin folder) in "Path" feild under "System Variables" as below ---> click "Ok" to save.

               


  2. Getting "java.net.BindExcpetion: address already in use: JVM_BIND" error.

      Solution : We are getting this error due to the previous process/session is still running and we need to kill that pid.

   Open CMD(command Prompt) as "Run as administaror " and type the below commands.

    i. First type below highlighted command to get the pid's running for the port number which you are using.

             


ii. Here i don't have any pid's, if you find any pid's kill them using below command.

             

               In above screenshot, 1234 is your pid
           




No comments:

Post a Comment