Skip to content

Latest commit

 

History

History
302 lines (201 loc) · 6.82 KB

File metadata and controls

302 lines (201 loc) · 6.82 KB

Perfect 👍 — here’s a clear, complete, copy-and-save deployment guide for your Jakarta EE (GlassFish 7) project. It includes all commands, what each one does, and the expected output or result — so you can follow it anytime in the future.


🧭 Jakarta EE Deployment Guide (GlassFish 7 + Maven WAR)

This guide explains how to build, deploy, stop, and redeploy a Jakarta EE web project manually using Maven and GlassFish 7.


⚙️ PREREQUISITES

Before starting, make sure you have:

  • Java 17+ installed

    java -version
  • Maven 3.8+ installed

    mvn -v
  • Your Jakarta EE project created (for example: jakarta-api-demo)

    ~/Desktop/coding/java/day1/jakarta-api-demo/
    

🧩 STEP 1 — Build the Project

From your project root:

cd ~/Desktop/coding/java/day1/jakarta-api-demo
mvn clean package

💡 What it does:

  • Cleans old builds
  • Compiles your Java source code
  • Packages it into a WAR file

🗂️ Result:

You should see a new file here:

target/jakarta-api-demo.war

🧰 STEP 2 — Download and Extract GlassFish 7

Download GlassFish:

wget https://download.eclipse.org/ee4j/glassfish/glassfish-7.0.4.zip

Unzip:

unzip glassfish-7.0.4.zip

This creates a folder named:

glassfish7/

📂 STEP 3 — Navigate to the Admin Tool Directory

Go to the bin folder that contains the asadmin command-line tool:

cd glassfish7/glassfish/bin

🚀 STEP 4 — Start the Default Domain

Start the built-in domain (domain1):

./asadmin start-domain

💡 What it does:

  • Starts the GlassFish server
  • Default HTTP port → 8080
  • Admin Console → http://localhost:4848

✅ Output Example:

Waiting for domain1 to start ...................
Successfully started the domain : domain1
domain  Location: /.../glassfish7/glassfish/domains/domain1
Log File: /.../glassfish7/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

🌐 STEP 5 — Deploy Your Application

Deploy your newly built WAR file:

./asadmin deploy ~/Desktop/coding/java/day1/jakarta-api-demo/target/jakarta-api-demo.war

💡 What it does:

  • Copies your WAR file into the GlassFish domain
  • Deploys it under /jakarta-api-demo
  • Makes it accessible at http://localhost:8080/jakarta-api-demo/

✅ Expected Output:

Application deployed with name jakarta-api-demo.
Command deploy executed successfully.

🧪 STEP 6 — Verify Deployment

Open in browser:

http://localhost:8080/jakarta-api-demo/index.html

or if your app has REST endpoints, try:

http://localhost:8080/jakarta-api-demo/api/users

🧹 STEP 7 — Stop the Domain

To gracefully stop the running GlassFish domain:

./asadmin stop-domain

✅ Output Example:

Waiting for the domain to stop ................
Command stop-domain executed successfully.

🧩 STEP 8 — Start or Stop Specific Domain (Optional)

GlassFish supports multiple domains. If you want to control a specific one (like domain1), use:

./asadmin start-domain domain1
./asadmin stop-domain domain1

🔁 STEP 9 — Redeploy / Update Your App

When you modify your code and rebuild it, you have two options:

Option A — Undeploy first, then deploy again:

./asadmin undeploy jakarta-api-demo
./asadmin deploy ~/Desktop/coding/java/day1/jakarta-api-demo/target/jakarta-api-demo.war

Option B — Force redeploy directly:

./asadmin deploy --force=true ~/Desktop/coding/java/day1/jakarta-api-demo/target/jakarta-api-demo.war

✅ This replaces the old version automatically.


🧾 STEP 10 — Check What’s Deployed

List all deployed applications:

./asadmin list-applications

Example output:

jakarta-api-demo <enabled>  (root)
Command list-applications executed successfully.

⚡ STEP 11 — Restart the Domain (If Needed)

If GlassFish behaves strangely or you’ve changed configs:

./asadmin restart-domain

✅ This will:

  • Stop the domain
  • Restart it automatically
  • Keep all previous deployments

🗃️ FILE LOCATION REFERENCE

Purpose Path
Project Root ~/Desktop/coding/java/day1/jakarta-api-demo/
Build Output (WAR) ~/Desktop/coding/java/day1/jakarta-api-demo/target/jakarta-api-demo.war
GlassFish Home ~/Desktop/coding/java/day1/glassfish7/
Admin Tool ~/Desktop/coding/java/day1/glassfish7/glassfish/bin/asadmin
Default Domain glassfish7/glassfish/domains/domain1
Server Log glassfish7/glassfish/domains/domain1/logs/server.log
Admin Console http://localhost:4848
App URL http://localhost:8080/jakarta-api-demo/

✅ QUICK COMMAND REFERENCE

Action Command
Build WAR mvn clean package
Start server ./asadmin start-domain
Deploy app ./asadmin deploy <path-to-war>
List apps ./asadmin list-applications
Undeploy app ./asadmin undeploy jakarta-api-demo
Redeploy app ./asadmin deploy --force=true <path-to-war>
Stop server ./asadmin stop-domain
Restart server ./asadmin restart-domain

💡 TIP: Create a Simple Deployment Script

You can automate this by saving the following as deploy.sh:

#!/bin/bash
PROJECT=~/Desktop/coding/java/day1/jakarta-api-demo
WAR=$PROJECT/target/jakarta-api-demo.war
GF=~/Desktop/coding/java/day1/glassfish7/glassfish/bin

cd $PROJECT
mvn clean package
$GF/asadmin deploy --force=true $WAR

Make it executable:

chmod +x deploy.sh

Run it anytime with:

./deploy.sh

That’s your full Jakarta EE + GlassFish deployment workflow — from build → deploy → stop → redeploy, all explained step by step.

Would you like me to format this as a clean Markdown document (README.md) so you can drop it directly into your project folder for future reference?