CentLinux | Learn How to Install CentOS/Rocky Linux Servers

Wednesday, December 22, 2021

Install Eclipse GlassFish Server on CentOS/RHEL 8

Install Eclipse GlassFish Server on CentOS / RHEL 8

Step by Step guide on how to install Eclipse GlassFish Server on CentOS / Red Hat Enterprise Linux (RHEL) 8 or Similar Linux distros.


Table of Contents:




What is Eclipse GlassFish Server? :

GlassFish is an open-source Jakarta EE platform application server project started by Sun Microsystems, then sponsored by Oracle Corporation, and now living at the Eclipse Foundation and supported by Payara, Oracle and Red Hat. The supported version under Oracle was called Oracle GlassFish Server. GlassFish is free software and was initially dual-licensed under two free software licences: the Common Development and Distribution License (CDDL) and the GNU General Public License (GPL) with the Classpath exception. After having been transferred to Eclipse, GlassFish remained dual-licensed, but the CDDL license was replaced by the Eclipse Public License (EPL).

GlassFish is the Eclipse implementation of Jakarta EE (formerly the reference implementation from Oracle) and as such supports EJB, JPA, JSF, JMS, RMI, JSP, servlets, etc. This allows developers to create enterprise applications that are portable and scalable, and that quickly become legacy technologies. Optional components can also be installed for additional services.

Built on a modular kernel powered by OSGi, GlassFish runs straight on top of the Apache Felix implementation. It also runs with Equinox OSGi or Knopflerfish OSGi runtimes. HK2 abstracts the OSGi module system to provide components, which can also be viewed as services. Such services can be discovered and injected at runtime.

GlassFish is based on source code released by Sun and Oracle Corporation's TopLink persistence system. It uses a derivative of Apache Tomcat as the servlet container for serving web content, with an added component called Grizzly which uses Java non-blocking I/O (NIO) for scalability and speed.

Recommended Books: Jakarta EE Cookbook: Practical recipes for enterprise Java developers to deliver large scale applications with Jakarta EE, 2nd Edition by Packt Publishing


Environment Specification:

We are using a minimal RHEL 8 virtual machine with following specifications.

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 2 GB
  • Storage - 20 GB
  • Operating System - Red Hat Enterprise Linux 8.5
  • Hostname – glassfish-01.centlinux.com
  • IP Address - /24


Update Linux Software Packages:

By using a SSH client, connect with glassfish-01.centlinux.com as root user.

Build cache of your enabled yum repositories.

# dnf makecache

Execute following dnf command to update installed software packages in you Linux server.

# dnf update -y

If the above command updates your Linux Kernel then you should reboot your Linux operating system with the new Kernel.

# reboot

After installation and reboot, verify the Linux operating system and Linux Kernel versions.

# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.5 (Ootpa)

# uname -r


Install GlassFish Prerequisites:

You are required wget and unzip commands to download and extract GlassFish installation files.

Therefore, install wget and unzip now by using dnf command.

# dnf install -y wget unzip

Eclipse GlassFish Server 6.2 requires Java JDK 11.

You can either install Oracle JDK or use OpenJDK instead.

Both works fine for Eclipse GlassFish Server 6.2.

Here, we are installing OpenJDK 11 from default Red Hat repositories.

# dnf install -y java-11-openjdk

After successful installation of Java Development Kit (JDK), verify the version of Java by using following command.

# java -version
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)


Create Linux User and Group:

Create a Linux user to own GlassFish software and processes.

# useradd -s /sbin/nologin glassfish


Install Eclipse GlassFish Server:

You can download GlassFish Software from their Official website.


Copy the URL from the above download page and then execute following wget command at Linux CLI to download GlassFish software.

# wget https://www.eclipse.org/downloads/download.php?file=/ee4j/glassfish/glassfish-6.2.3.zip -O ~/glassfish-6.2.3.zip
--2021-12-21 14:27:40--  https://www.eclipse.org/downloads/download.php?file=/ee4j/glassfish/glassfish-6.2.3.zip
Resolving www.eclipse.org (www.eclipse.org)...
Connecting to www.eclipse.org (www.eclipse.org)||:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.3.zip [following]
--2021-12-21 14:27:42--  https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.3.zip
Resolving download.eclipse.org (download.eclipse.org)...
Connecting to download.eclipse.org (download.eclipse.org)||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 118233273 (113M) [application/zip]
Saving to: ‘/root/glassfish-6.2.3.zip’

/root/glassfish-6.2 100%[===================>] 112.76M   921KB/s    in 1m 49s

2021-12-21 14:29:33 (1.03 MB/s) - ‘/root/glassfish-6.2.3.zip’ saved [118233273/118233273]

After successful download, extract the downloaded file by using unzip command.

# unzip -d /opt/ glassfish-6.2.3.zip

Change the ownership of GlassFish software by executing following Linux command.

# chown -R glassfish:glassfish /opt/glassfish6/


Create Systemd Service Unit:

To configure autostart of Eclipse GlassFish server, you need to create a Systemd service unit.

Use vim text editor to create a Systemd service unit as follows.

# vi /usr/lib/systemd/system/glassfish.service

Add following lines in this file.

Description = GlassFish Server v6.2
After = syslog.target network.target

User = glassfish
ExecStart = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking

WantedBy = multi-user.target

Enable and start GlassFish service.

# systemctl enable --now glassfish.service
Created symlink /etc/systemd/system/multi-user.target.wants/glassfish.service → /usr/lib/systemd/system/glassfish.service.

Verify the status of GlassFish service.

# systemctl status glassfish.service
● glassfish.service - GlassFish Server v6.2
   Loaded: loaded (/usr/lib/systemd/system/glassfish.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-12-21 14:43:23 EST; 11s ago
  Process: 3149 ExecStart=/usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver-cli.jar start-domain (code=ex>
 Main PID: 3168 (java)
    Tasks: 100 (limit: 12267)
   Memory: 335.3M
   CGroup: /system.slice/glassfish.service
           └─3168 /usr/lib/jvm/java-11-openjdk- -cp /opt/glassfish6/glassfish/modules/>

Dec 21 14:43:12 glassfish-01.centlinux.com systemd[1]: Starting GlassFish Server v6.2...
Dec 21 14:43:22 glassfish-01.centlinux.com java[3149]: Waiting for domain1 to start .........
Dec 21 14:43:22 glassfish-01.centlinux.com java[3149]: Successfully started the domain : domain1
Dec 21 14:43:22 glassfish-01.centlinux.com java[3149]: domain  Location: /opt/glassfish6/glassfish/domains/domain1
Dec 21 14:43:22 glassfish-01.centlinux.com java[3149]: Log File: /opt/glassfish6/glassfish/domains/domain1/logs/server.log
Dec 21 14:43:22 glassfish-01.centlinux.com java[3149]: Admin Port: 4848
Dec 21 14:43:22 glassfish-01.centlinux.com java[3149]: Command start-domain executed successfully.
Dec 21 14:43:23 glassfish-01.centlinux.com systemd[1]: Started GlassFish Server v6.2.


Configure Linux Firewall:

Eclipse GlassFish Server uses following service ports.

  • 4848 - Administration Console
  • 8080 - HTTP Service
  • 8181 - HTTPS Service

Therefore, allow these ports in Linux Firewall to make GlassFish Server accessible across the network.

# firewall-cmd --permanent --add-port={4848,8080,8181}/tcp
# firewall-cmd --reload


Set GlassFish Admin Password:

Add GlassFish binaries in PATH environment variable, to make them executable from any path.

# sed -i 's/^PATH=*/PATH=\/opt\/glassfish6\/bin:/g' ~/.bash_profile
# source ~/.bash_profile

Note: Default password for admin user is blank.

Use asadmin command and set a password for GlassFish Admin user.

# asadmin --port 4848 change-admin-password
Enter admin user name [default: admin]>
Enter the admin password>
Enter the new admin password>
Enter the new admin password again>
Command change-admin-password executed successfully.


Configure HTTPS for GlassFish Server:

By default, Glassfish Admin Console is running as a clear text HTTP service. Run following command to enable secure administration console.

# asadmin --host glassfish-01.centlinux.com --port 4848 enable-secure-admin
Enter admin user name>  admin
Enter admin password for user "admin">
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

Restart GlassFish server to apply changes.

# systemctl restart glassfish.service

Browse URL https://glassfish-01.centlinux.com:4848/ from a client's browser. You have to ignore certificate warning and add exception in your browser.


Login as Admin user with password, that we have set in previous steps.


You have successfully login to Glassfish Admin Console.

Now, Browse URLs http://glassfish-01.centlinux.com/ and https://glassfish-01.centlinux.com/ from a client's browser.

Both URLs will bring you to the same page. The only difference is that, former will serve you a clear text HTTP version, however the later will serve an encrypted HTTPS version of the same web page.




In this article, you have learned how to install Eclipse GlassFish Server on CentOS / Red Hat Enterprise Linux (RHEL) 8 or similar Linux distros.

If you find this article useful? Consider supporting us by Buy Me A Coffee

No comments:

Post a Comment

© 2023 CentLinux. All Rights Reserved.