Skip to content

jagadapi240/Nexus-Java-Web-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 

Repository files navigation

Java Web Calculator โ€“ Manual CI/CD (Multi-Version Deployment)

This project demonstrates a manual buildโ€“stageโ€“deploy pipeline for a Java-based Web Calculator App, progressively enhanced across three versions:

Version Features Included WAR File Name Description
v0.0.1 Addition only webapp-add-0.0.1.war Basic calculator with addition feature
v0.0.2 Addition + Subtraction webapp-add-sub-0.0.2.war Enhanced version with subtraction functionality
v0.0.3 Addition + Subtraction + Multiplication webapp-add-sub-mul-0.0.3.war Final version with multiplication added

โš™๏ธ Infrastructure Overview

Server Purpose Key Ports Tools Installed
Build Server Compiles and packages the code using Maven 22 OpenJDK 17, Maven, Git
Nexus Server (Staging) Stores the .war artifacts 22, 8081 OpenJDK 17, Nexus Repository 3
Deploy Server Hosts the final app via Tomcat 22, 8080 OpenJDK 17, Apache Tomcat 9

๐Ÿงฑ 1. Build Server Setup & Packaging

1 11 12 13 14

Steps

# 1๏ธโƒฃ Hostname setup
sudo hostnamectl set-hostname build
sudo init 6

# 2๏ธโƒฃ System update & Java installation
sudo apt -y update
sudo apt install openjdk-17-jre-headless -y

# 3๏ธโƒฃ Install Maven
sudo apt install maven -y
java -version
mvn -version

# 4๏ธโƒฃ Clone the repository
git clone https://github.com/mrtechreddy/Java-Web-Calculator-App.git
cd Java-Web-Calculator-App/

# 5๏ธโƒฃ Validate & package source
mvn validate
mvn clean package

# 6๏ธโƒฃ Verify WAR files in target/
cd target/
ls

Multi-Version Packaging Process

15 16 17 18 19 20 21 22

Each time a feature is added, the app is rebuilt with a version tag:

Step Feature Added Command Output Artifact
1 Addition mvn clean package webapp-add-0.0.1.war
2 Addition + Subtraction Update code โ†’ mvn clean package webapp-add-sub-0.0.2.war
3 Addition + Sub + Mul Update code โ†’ mvn clean package webapp-add-sub-mul-0.0.3.war

Deploy to Nexus

Update your pom.xml or /etc/maven/settings.xml:

<distributionManagement>
  <repository>
    <id>Java-Cal-App</id>
    <url>http://51.21.200.175:8081/repository/Java-Cal-App/</url>
  </repository>
</distributionManagement>

Then push build artifacts:

mvn deploy

๐Ÿงฉ 2. Nexus Repository Server (Staging)

Setup Steps

3 28 29 30 31 32 8 9 10
sudo hostnamectl set-hostname nexus
sudo init 6
sudo apt -y update
sudo apt install openjdk-17-jre-headless -y

# Download and extract Nexus
wget https://download.sonatype.com/nexus/3/nexus-3.85.0-03-linux-x86_64.tar.gz
tar -xvzf nexus-3.85.0-03-linux-x86_64.tar.gz
cd nexus-3.85.0-03/bin/

# Start Nexus service
./nexus start
sudo apt install net-tools -y
sudo netstat -ntpl

Access Nexus

  • URL: http://51.21.200.175:8081

  • Login:

    • Username: admin
    • Password: /home/ubuntu/sonatype-work/nexus3/admin.password

Create a hosted Maven repository named Java-Cal-App.

After each deployment:

Version Artifact Path
0.0.1 /repository/Java-Cal-App/com/web/cal/webapp-add/0.0.1/webapp-add-0.0.1.war
0.0.2 /repository/Java-Cal-App/com/web/cal/webapp-add-sub/0.0.2/webapp-add-sub-0.0.2.war
0.0.3 /repository/Java-Cal-App/com/web/cal/webapp-add-sub-mul/0.0.3/webapp-add-sub-mul-0.0.3.war

๐Ÿงพ 3. Deploy Server (Tomcat Deployment)

Setup

2 4 23 24 25
sudo hostnamectl set-hostname deploy
sudo init 6
sudo apt -y update
sudo apt install openjdk-17-jre-headless -y

# Download Apache Tomcat 9
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.111/bin/apache-tomcat-9.0.111.tar.gz
tar -xvzf apache-tomcat-9.0.111.tar.gz
cd apache-tomcat-9.0.111/

# Configure admin access
vi conf/tomcat-users.xml
# Add:
# <user username="admin" password="admin123" roles="manager-gui,admin-gui"/>

# Remove access restrictions
sudo vi ./webapps/manager/META-INF/context.xml
sudo vi ./webapps/host-manager/META-INF/context.xml
# Comment out or remove <Valve ...> line

# Start Tomcat
./bin/startup.sh

Deploy WAR Files (Progressive Versions)

26 27

Deploy v0.0.1 (Addition Only)

cd apache-tomcat-9.0.111/webapps/
wget http://<NEXUS-IP>:8081/repository/Java-Cal-App/com/web/cal/webapp-add/0.0.1/webapp-add-0.0.1.war

Access โ†’ http://<DEPLOY-IP>:8080/webapp-add

Deploy v0.0.2 (Add + Sub)

wget http://<NEXUS-IP>:8081/repository/Java-Cal-App/com/web/cal/webapp-add-sub/0.0.2/webapp-add-sub-0.0.2.war

Access โ†’ http://<DEPLOY-IP>:8080/webapp-add-sub

Deploy v0.0.3 (Add + Sub + Mul)

wget http://<NEXUS-IP>:8081/repository/Java-Cal-App/com/web/cal/webapp-add-sub-mul/0.0.3/webapp-add-sub-mul-0.0.3.war

Access โ†’ http://<DEPLOY-IP>:8080/webapp-add-sub-mul

Restart Tomcat after each deployment:

./bin/shutdown.sh
./bin/startup.sh

๐Ÿงฎ Validation Summary

Stage Output Verification
Build .war in /target ls target/
Stage Artifact in Nexus Nexus GUI โ†’ browse Java-Cal-App
Deploy App running in browser Access via Tomcat on port 8080

๐Ÿงฐ Troubleshooting

Issue Cause Fix
Nexus not reachable Service not started cd nexus-3.85.0-03/bin && ./nexus start
Maven deploy fails Wrong repo credentials Check <servers> in settings.xml
Tomcat 403 error Context.xml restricted Comment out <Valve> line
WAR not visible Cached deployment Clear /webapps and redeploy

๐Ÿง  Tech Stack

  • Java 17
  • Apache Maven 3
  • Sonatype Nexus 3
  • Apache Tomcat 9
  • Ubuntu 22.04 LTS (AWS EC2)

๐Ÿ‘จโ€๐Ÿ’ป Author

Sivaiah Jagadapi Power BI Developer | DevOps Learner | Cloud Automation Explorer ๐Ÿ“ Hyderabad, India ๐Ÿ—‚ Glintsoft Infotech Pvt Ltd ๐Ÿ“ง [email protected]


๐Ÿ End-to-End Flow (All Versions)

Source Code v1 โ†’ Build (Maven) โ†’ WAR v0.0.1 โ†’ Nexus Repo โ†’ Tomcat Deploy (Addition)
        โ†“
Source Code v2 โ†’ Build (Maven) โ†’ WAR v0.0.2 โ†’ Nexus Repo โ†’ Tomcat Deploy (Add + Sub)
        โ†“
Source Code v3 โ†’ Build (Maven) โ†’ WAR v0.0.3 โ†’ Nexus Repo โ†’ Tomcat Deploy (Add + Sub + Mul)

โœ… Final Outcome: A fully working 3-tier manual CI/CD pipeline demonstrating Java web app build, artifact staging in Nexus, and deployment to Tomcat โ€” versioned incrementally as new calculator features are added.


---

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published