Deploying a Java Web Application in Apache Tomcat App Server.
This project is to copy a .war file from JFrog Artifactory to an app server (Tomcat) to serve content to users. Tomcat is the application server to host java application.
- You must have an AWS account to create infrastructure resources on AWS cloud.
- GitHub or Bitbucket to clone your code for the build process.
- JFrog Antifactory account to store artifacts files.
Lets begin the process — Head over to your JFrog Artifactory account to check where your artifact was saved. Below is the screenshot. In the screenshot my .war file is saved under the name projectdevcloud
The next step is to create a Tomcat server to host the code from JFrog. Login to the server and change user to root user with the command sudo su -
Head over to the Tomcat website — https://tomcat.apache.org/download-80.cgi to download the version of Tomcat specified by the developer. In my case the developer requires I download Tomcat 8 version.
Right click on the link and go to your application server and download Tomcat in the /opt location with the command wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.76/bin/apache-tomcat-8.5.76.zip. After the download unzip the file with the command unzip apach-tomcat-8.5.76 .zip. Screenshot blow
After Tomcat is unzip. change directory to apache-tomcat-8.5.76 with the command cd apache-tomcat-8.5.76/ and with another command ls -la which gives you the files in the home directory call Catalina home directory which is the directory where the application will be hosted under the folder Webapps
In the Catalina home directory you will see a folder call bin. Change directory to the bin folder with the command cd bin/ and then ls -la to see what is inside of the bin folder to configure some settings.
In the bin folder we realize all the scripts don’t have the execution permission so we need to change the permission with the command Chmod +x ./*
After enabling the permission look for a script name startup.sh. Tomcat needs to be started with the command ./startup.sh to start the Tomcat application. Once you run the scripts Tomcat should start. The server didn’t start because we haven’t installed Java JDK.
Install Java JDK with the command the command amazon-linux-extras install java OpenJDK if you are downloading JDK 11 or yum install OpenJDK if you downloading OpenJDK 1.8.0 version. Check the version of Java install with the command Java -version
After installing Java. Head over to the Catalina home directory with the command cd bin/ and start the Tomcat app server with the command ./startup.sh
Use netstate -tupln to check if tomcat port 8080 is open and listen.
After head over to the AWS management console and copy the IP Address to the web browser to see if Tomcat server landing page is running 184.108.40.206:8080
After seeing that the landing page is working. The .war files saved in the JFrog will need to be copied to the Catalina home directory insider the folder called Webapps with the command cd webapps/ and the command ls -la to see what is inside the webapps folder.
Head over to your JFrog account and copy the URL to your app server and use the wget command and authenticate with a username and password to download
Check your Webapps folder to see if Code is copied to the webapps folder.
Check your web browser to with the with link to see if java code is successfully deployed to Tomcat and is in a working state — http://220.127.116.11:8080/dptweb-1.0/login
In conclusion — This is a simple step by step tutorial on how to successfully deploy a Java Web Application in Apache Tomcat App Server. Thank you so much for stopping by my page to read my mini project with mensahcloud. A very grateful.