aurelia
unix
php
alpine
0b
+
+
+
+
julia
neo4j
+
nest
+
mocha
eclipse
+
+
$
+
+
!=
yaml
+
+
couchdb
+
+
+
+
+
+
+
vscode
+
+
+
ractive
+
@
+
cassandra
babel
dart
mvn
+
ember
+
haskell
+
rider
+
bundler
weaviate
+
adonis
+
+
arch
pandas
!!
graphql
mysql
rb
+
+
+
clickhouse
zorin
alpine
_
+
+
vb
+
+
+
ubuntu
+
+
+
webstorm
?
+
+
&
=
+
hugging
Back to Blog
☕ Java Application Servers on AlmaLinux: Tomcat & WildFly Complete Guide
AlmaLinux Java Tomcat

☕ Java Application Servers on AlmaLinux: Tomcat & WildFly Complete Guide

Published Sep 13, 2025

Master Java application deployment with Tomcat and WildFly on AlmaLinux! Learn installation, configuration, WAR deployment, clustering, and performance tuning. Perfect for enterprise Java developers.

5 min read
0 views
Table of Contents

☕ Java Application Servers on AlmaLinux: Tomcat & WildFly Complete Guide

Welcome to the enterprise world of Java application deployment! 🚀 Today we’ll master two of the most powerful Java application servers - Apache Tomcat and WildFly (formerly JBoss). Think of these as the rocket engines that power Java applications used by millions of businesses worldwide! 🏢

From banking systems to e-commerce platforms, Java application servers are the backbone of enterprise computing. Whether you’re deploying servlets, JSPs, or full Jakarta EE applications, this guide will make you a Java deployment expert on AlmaLinux! 💪

🤔 Why are Java Application Servers Important?

Java application servers are the powerhouses of enterprise computing! ⚡ Here’s why they’re essential:

  • 🏢 Enterprise Standard - Powers Fortune 500 companies globally
  • 🚀 Massive Scalability - Handle millions of concurrent users
  • 🔧 Complete Platform - Everything needed for enterprise applications
  • 💰 Cost Effective - Open source alternatives to expensive commercial servers
  • 🛡️ Battle-Tested Security - Enterprise-grade security features built-in
  • 🌍 Universal Compatibility - Write once, run anywhere with Java
  • 📈 High Performance - Optimized for heavy workloads and transactions
  • 🤝 Huge Ecosystem - Thousands of libraries and frameworks available

🎯 What You Need

Before we deploy enterprise Java applications, ensure you have:

AlmaLinux system (physical or virtual machine)
Root or sudo access for installing servers
At least 2GB RAM (4GB+ recommended for production)
Java JDK installed (we’ll help you set this up)
Basic Java knowledge (servlets, JSP concepts helpful)
Text editor like nano or vim
Internet connection for downloading packages
Free disk space (at least 1GB for server installation)

📝 Installing Java Development Kit (JDK)

Let’s start by installing Java, the foundation for everything! ☕

# Update your system first
sudo dnf update -y
# This ensures you have the latest packages

# Install OpenJDK 11 (LTS version)
sudo dnf install -y java-11-openjdk java-11-openjdk-devel
# Installs Java runtime and development kit

# Install OpenJDK 17 (latest LTS)
sudo dnf install -y java-17-openjdk java-17-openjdk-devel
# Installs newer Java version for modern applications

# Check Java installation
java -version
# Should show: openjdk version "11.0.x" or "17.0.x"

javac -version
# Should show Java compiler version

# Set JAVA_HOME environment variable
echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Sets up Java environment variables

# Verify JAVA_HOME
echo $JAVA_HOME
# Should show: /usr/lib/jvm/java-11-openjdk

Switch between Java versions if needed:

# List available Java versions
sudo alternatives --config java
# Shows all installed Java versions

# Select default Java version (enter the number)
sudo alternatives --config javac
# Sets default Java compiler version

🔧 Installing and Configuring Apache Tomcat

Apache Tomcat is the world’s most popular Java servlet container! 🐱

# Create tomcat user for security
sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat
# Creates dedicated user for running Tomcat

# Download Tomcat 10 (latest stable)
cd /tmp
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.16/bin/apache-tomcat-10.1.16.tar.gz
# Downloads Tomcat (check for latest version at tomcat.apache.org)

# Extract and install Tomcat
sudo tar xzvf apache-tomcat-10.1.16.tar.gz -C /opt/tomcat --strip-components=1
# Extracts Tomcat to /opt/tomcat directory

# Set proper permissions
sudo chown -R tomcat: /opt/tomcat
sudo chmod +x /opt/tomcat/bin/*.sh
# Ensures tomcat user owns all files

Create systemd service for Tomcat:

# Create Tomcat service file
sudo cat > /etc/systemd/system/tomcat.service << 'EOF'
[Unit]
Description=Apache Tomcat Web Application Server
After=network.target

[Service]
Type=forking
User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
EOF
# This creates a systemd service for automatic startup

# Reload systemd and start Tomcat
sudo systemctl daemon-reload
sudo systemctl enable tomcat
sudo systemctl start tomcat
# Starts Tomcat server

# Check Tomcat status
sudo systemctl status tomcat
# Should show "active (running)"

# Test Tomcat
curl http://localhost:8080
# Should return Tomcat welcome page HTML

Configure Tomcat management interface:

# Configure Tomcat users for management
sudo cat > /opt/tomcat/conf/tomcat-users.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
  
  <!-- User roles -->
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  
  <!-- Admin user with secure password -->
  <user username="admin" password="SecureAdminPass123!" 
        roles="manager-gui,manager-script,manager-status,admin-gui,admin-script"/>
        
  <!-- Deploy user for automated deployments -->
  <user username="deployer" password="DeployPass456!" 
        roles="manager-script"/>
</tomcat-users>
EOF
# Sets up admin users for Tomcat management

# Allow remote access to Manager app (for production, restrict IPs)
sudo sed -i '/<Valve/d' /opt/tomcat/webapps/manager/META-INF/context.xml
sudo sed -i '/<Valve/d' /opt/tomcat/webapps/host-manager/META-INF/context.xml
# Removes IP restrictions (configure properly for production!)

# Restart Tomcat
sudo systemctl restart tomcat
# Applies configuration changes

🌟 Installing and Configuring WildFly

WildFly is the powerful, full Jakarta EE application server! 🔥

# Create wildfly user
sudo useradd -r -m -U -d /opt/wildfly -s /bin/false wildfly
# Creates dedicated user for WildFly

# Download WildFly
cd /tmp
wget https://github.com/wildfly/wildfly/releases/download/30.0.0.Final/wildfly-30.0.0.Final.tar.gz
# Downloads WildFly (check for latest at wildfly.org)

# Extract and install WildFly
sudo tar xzvf wildfly-30.0.0.Final.tar.gz -C /opt/
sudo mv /opt/wildfly-30.0.0.Final /opt/wildfly
# Installs WildFly to /opt/wildfly

# Set permissions
sudo chown -R wildfly: /opt/wildfly
# Ensures wildfly user owns all files

# Configure WildFly to start as service
sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
# Copies systemd service file

# Configure WildFly service
sudo cat > /etc/wildfly/wildfly.conf << 'EOF'
# WildFly configuration

# Bind to all network interfaces
WILDFLY_BIND=0.0.0.0

# Bind management interface
WILDFLY_MANAGEMENT_BIND=0.0.0.0

# Server mode (standalone or domain)
WILDFLY_MODE=standalone

# Configuration file
WILDFLY_CONFIG=standalone.xml

# Console log
WILDFLY_CONSOLE_LOG=/var/log/wildfly/console.log
EOF
# Creates WildFly configuration

# Create log directory
sudo mkdir -p /var/log/wildfly
sudo chown wildfly: /var/log/wildfly
# Creates directory for WildFly logs

# Start WildFly
sudo systemctl daemon-reload
sudo systemctl enable wildfly
sudo systemctl start wildfly
# Starts WildFly server

# Create admin user
sudo -u wildfly /opt/wildfly/bin/add-user.sh
# Follow prompts to create management user
# Choose: a) Management User
# Username: admin
# Password: SecurePass123!

Configure WildFly for production:

# Configure JVM settings for WildFly
sudo cat >> /opt/wildfly/bin/standalone.conf << 'EOF'

# Production JVM settings
JAVA_OPTS="$JAVA_OPTS -Xms1024m -Xmx2048m"
JAVA_OPTS="$JAVA_OPTS -XX:MaxMetaspaceSize=512m"
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman"
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"

# Garbage collection tuning
JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC"
JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=200"
EOF
# Optimizes JVM for production use

# Enable remote management access (configure firewall properly!)
sudo -u wildfly /opt/wildfly/bin/jboss-cli.sh --connect << 'EOF'
/interface=management:write-attribute(name=inet-address,value="0.0.0.0")
/interface=public:write-attribute(name=inet-address,value="0.0.0.0")
reload
EOF
# Configures network interfaces

✅ Deploying Java Applications

Now let’s deploy applications to both servers! 🚀

Deploy to Tomcat

# Create a simple test application
mkdir -p ~/webapp/WEB-INF
cd ~/webapp

# Create web.xml deployment descriptor
cat > WEB-INF/web.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
         http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    
    <display-name>Test Application</display-name>
    
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
EOF

# Create a JSP page
cat > index.jsp << 'EOF'
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>Java App on AlmaLinux</title>
    <style>
        body { font-family: Arial, sans-serif; padding: 50px; text-align: center; }
        .info { background: #f0f0f0; padding: 20px; border-radius: 10px; margin: 20px auto; max-width: 600px; }
    </style>
</head>
<body>
    <h1>🎉 Java Application Running Successfully!</h1>
    <div class="info">
        <h2>Server Information</h2>
        <p>Server: <%= application.getServerInfo() %></p>
        <p>Java Version: <%= System.getProperty("java.version") %></p>
        <p>OS: <%= System.getProperty("os.name") %></p>
        <p>Current Time: <%= new java.util.Date() %></p>
        <p>Session ID: <%= session.getId() %></p>
    </div>
    <div class="info">
        <h2>🚀 Deployment Successful!</h2>
        <p>Your Java application is running on AlmaLinux!</p>
    </div>
</body>
</html>
EOF

# Create WAR file
jar -cvf testapp.war *
# Packages application into WAR file

# Deploy to Tomcat
sudo cp testapp.war /opt/tomcat/webapps/
# Tomcat auto-deploys WAR files

# Access the application
curl http://localhost:8080/testapp/
# Should show your JSP page output

Deploy to WildFly

# Deploy using WildFly CLI
sudo -u wildfly /opt/wildfly/bin/jboss-cli.sh --connect << EOF
deploy ~/webapp/testapp.war
EOF
# Deploys WAR file to WildFly

# Or copy to deployments directory
sudo cp ~/webapp/testapp.war /opt/wildfly/standalone/deployments/
# WildFly auto-deploys from this directory

# Check deployment status
sudo -u wildfly /opt/wildfly/bin/jboss-cli.sh --connect --command="deployment-info"
# Shows deployed applications

# Access the application
curl http://localhost:8080/testapp/
# Should show your application

🎮 Quick Examples

Let’s practice with real enterprise scenarios! 🎯

Example 1: Configure Database Connection Pool

# Configure database connection in Tomcat
sudo cat >> /opt/tomcat/conf/context.xml << 'EOF'
    <!-- PostgreSQL Connection Pool -->
    <Resource name="jdbc/PostgresDB"
              auth="Container"
              type="javax.sql.DataSource"
              driverClassName="org.postgresql.Driver"
              url="jdbc:postgresql://localhost:5432/myapp"
              username="dbuser"
              password="dbpass"
              maxTotal="20"
              maxIdle="10"
              maxWaitMillis="10000"
              validationQuery="SELECT 1"
              testOnBorrow="true"/>
EOF

# Download PostgreSQL JDBC driver
cd /opt/tomcat/lib
sudo wget https://jdbc.postgresql.org/download/postgresql-42.6.0.jar
sudo chown tomcat: postgresql-42.6.0.jar

# Restart Tomcat
sudo systemctl restart tomcat
# Applies database configuration

Example 2: Enable SSL/HTTPS

# Generate SSL certificate for Tomcat
sudo keytool -genkey -alias tomcat -keyalg RSA -keystore /opt/tomcat/conf/keystore.jks \
  -storepass changeit -validity 365 -keysize 2048
# Creates self-signed certificate

# Configure SSL in Tomcat server.xml
sudo cat >> /opt/tomcat/conf/server.xml << 'EOF'
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="conf/keystore.jks"
                        certificateKeystorePassword="changeit"
                        type="RSA" />
        </SSLHostConfig>
    </Connector>
EOF

# For WildFly SSL configuration
sudo -u wildfly /opt/wildfly/bin/jboss-cli.sh --connect << 'EOF'
/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding=https, security-realm=ApplicationRealm, enable-http2=true)
reload
EOF
# Enables HTTPS on WildFly

Example 3: Configure Clustering

# Configure Tomcat clustering
sudo cat > /opt/tomcat/conf/cluster.xml << 'EOF'
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
  <Manager className="org.apache.catalina.ha.session.DeltaManager"
           expireSessionsOnShutdown="false"
           notifyListenersOnReplication="true"/>
           
  <Channel className="org.apache.catalina.tribes.group.GroupChannel">
    <Membership className="org.apache.catalina.tribes.membership.McastService"
                address="228.0.0.4"
                port="45564"
                frequency="500"
                dropTime="3000"/>
                
    <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
              address="auto"
              port="4000"
              autoBind="100"
              selectorTimeout="5000"
              maxThreads="6"/>
              
    <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
      <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
    </Sender>
  </Channel>
  
  <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
  <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
EOF
# This enables session replication between Tomcat instances

# For WildFly, use standalone-ha.xml configuration
sudo -u wildfly /opt/wildfly/bin/standalone.sh -c standalone-ha.xml
# Starts WildFly in High Availability mode

🚨 Fix Common Problems

Encountering issues? Here are solutions to common problems:

Problem 1: Port Already in Use

# Check what's using port 8080
sudo netstat -tlnp | grep :8080
# Shows process using the port

# Kill the process if needed
sudo kill -9 <PID>
# Replace <PID> with actual process ID

# Or change Tomcat port
sudo sed -i 's/port="8080"/port="8090"/' /opt/tomcat/conf/server.xml
# Changes Tomcat to port 8090

# Change WildFly port
sudo -u wildfly /opt/wildfly/bin/jboss-cli.sh --connect << EOF
/socket-binding-group=standard-sockets/socket-binding=http:write-attribute(name=port,value=8090)
reload
EOF

Problem 2: Out of Memory Errors

# Increase Tomcat memory
sudo sed -i 's/CATALINA_OPTS=.*/CATALINA_OPTS="-Xms1024M -Xmx2048M -server -XX:+UseParallelGC"/' /etc/systemd/system/tomcat.service

# Increase WildFly memory
echo 'JAVA_OPTS="$JAVA_OPTS -Xms2048m -Xmx4096m"' >> /opt/wildfly/bin/standalone.conf

# Reload and restart services
sudo systemctl daemon-reload
sudo systemctl restart tomcat wildfly

# Monitor memory usage
jps -l  # List Java processes
jmap -heap <PID>  # Check heap usage

Problem 3: Application Won’t Deploy

# Check Tomcat logs
sudo tail -f /opt/tomcat/logs/catalina.out
# Shows deployment errors

# Check WildFly logs
sudo tail -f /opt/wildfly/standalone/log/server.log
# Shows WildFly errors

# Verify WAR file structure
jar -tf yourapp.war | head -20
# Should show WEB-INF/ and other directories

# Check permissions
sudo chown tomcat: /opt/tomcat/webapps/yourapp.war
sudo chown wildfly: /opt/wildfly/standalone/deployments/yourapp.war

Problem 4: Cannot Access Manager Interface

# Verify tomcat-users.xml is correct
sudo cat /opt/tomcat/conf/tomcat-users.xml
# Check user roles and passwords

# Check context.xml for IP restrictions
sudo grep Valve /opt/tomcat/webapps/manager/META-INF/context.xml
# Remove or modify Valve element for access

# Restart Tomcat after changes
sudo systemctl restart tomcat

# Test with curl
curl -u admin:SecureAdminPass123! http://localhost:8080/manager/text/list
# Should list deployed applications

Problem 5: Slow Performance

# Enable access logging for analysis
# For Tomcat, in server.xml:
sudo sed -i 's/<!--.*Valve className="org.apache.catalina.valves.AccessLogValve".*-->//' /opt/tomcat/conf/server.xml

# Monitor thread usage
jstack <PID> | grep "java.lang.Thread.State" | sort | uniq -c
# Shows thread states

# Enable JMX monitoring
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=9090"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"

# Use jconsole or jvisualvm to monitor
jconsole localhost:9090

📋 Simple Commands Summary

Here’s your Java server quick reference! 📖

CommandPurposeExample
systemctl start tomcatStart TomcatStarts Tomcat service
systemctl start wildflyStart WildFlyStarts WildFly service
/opt/tomcat/bin/shutdown.shStop TomcatGraceful shutdown
jboss-cli.sh --connectWildFly CLIManagement interface
jar -cvf app.war *Create WAR filePackage application
jps -lList Java processesShows running Java apps
keytool -list -keystore keystore.jksList certificatesView SSL certs
tail -f catalina.outView Tomcat logsReal-time log monitoring

💡 Tips for Success

Follow these best practices for enterprise Java deployments! 🌟

JVM Tuning is Critical

  • Monitor heap usage regularly
  • Use appropriate garbage collector
  • Set min and max heap sizes properly
  • Enable GC logging for analysis

🔒 Security First

  • Change all default passwords
  • Use SSL/TLS for production
  • Implement proper authentication
  • Keep servers updated regularly

📊 Monitor Performance

  • Enable access logs
  • Use APM tools (New Relic, AppDynamics)
  • Monitor JVM metrics
  • Set up alerting for issues

🚀 Optimize for Production

  • Use connection pooling
  • Enable caching where appropriate
  • Configure session persistence
  • Implement load balancing

📦 Deployment Best Practices

  • Use CI/CD pipelines
  • Version your WAR files
  • Test in staging first
  • Keep rollback plans ready

🔧 Resource Management

  • Set proper thread pool sizes
  • Configure connection timeouts
  • Limit request sizes
  • Implement rate limiting

🏆 What You Learned

Congratulations! You’ve mastered Java application servers on AlmaLinux! 🎉 Here’s what you accomplished:

Installed and configured Apache Tomcat for servlet containers
Set up WildFly for full Jakarta EE applications
Deployed Java applications using WAR files
Configured database connections and connection pooling
Implemented SSL/HTTPS for secure connections
Set up clustering for high availability
Optimized JVM settings for production performance
Troubleshot common issues like a senior engineer

🎯 Why This Matters

Java application servers aren’t just technology - they’re the backbone of enterprise computing that powers the global economy! 🌟

From banking transactions to e-commerce platforms, from healthcare systems to government services, Java application servers handle the critical workloads that society depends on. By mastering Tomcat and WildFly on AlmaLinux, you’ve gained skills that are in massive demand across every industry.

Whether you’re building microservices, deploying legacy applications, or creating the next enterprise platform, these Java deployment skills will accelerate your career and enable you to build systems that scale to millions of users! 🚀

Remember: Java may be decades old, but it continues to evolve and power the world’s most important applications. Keep learning, keep building, and be proud that you’re part of the massive Java ecosystem! ⭐

Great job on completing this comprehensive Java application server guide! You’re now ready to deploy enterprise Java applications that power businesses worldwide! 🙌