7.7 C
Muhammad Nabeel
Muhammad Nabeel
Network and System Administrator

How to Install GlassFish 5 on RHEL and CENTOS 8

GlassFish is an open-source application server project started by Sun Microsystems for the Java EE platform, 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 licenses. So, in this post I will show how to install Glassfish 5 on RHEL 8 and CentOS 8.

GlassFish is the reference implementation of Java EE and as such supports Enterprise JavaBeans, JPA, JavaServer Faces, JMS, RMI, JavaServer Pages, servlets, etc. This allows developers to create enterprise applications that are portable and scalable, and that integrate with legacy technologies. Optional components can also be installed for additional services.

Step 1: Install Some necessary packages

Install wget and unzip using below commands

dnf install -y wget unzip

glassfish installation

Step 2: Install and Configure OpenJDK

dnf install -y java-1.8.0-openjdk

Open JDK installation

Set Java’s Home Environment

Run below command to find java path

update-alternatives --config java

Then copy that path and insert it into below file

Now Set Java’s Path in Your Environment using below command

vi .bash_profile

Now add below line in .bash_profile file

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-

Refresh .bash_file to make changes using below command

source .bash_profile

Run below commands to see the Java path you set and the java version.

java -version

Step 3: Installing Glassfish 5.0 on RHEL/CENTOS 8

We will install Glassfish Full platform.

Create a user for Glassfish.

useradd -s /sbin/nologin glassfish

Download Glassfish 5.0

wget http://download.oracle.com/glassfish/5.0/release/glassfish-5.0.zip

Unzip glassfish-5.0.zip file.

unzip -d /opt/ glassfish-5.0.zip

Assign the ownership of /opt/glassfish5 directory to glassfish user which we have created above.

chown -R glassfish:glassfish /opt/glassfish5/

Step 4: Create a Glassfish Service on CentOS 8 / RHEL 8

Create systemd service (glassfish.service) for Glassfish server

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

Now add below script in this file

Description = GlassFish Server v5.0
After = syslog.target network.target

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

WantedBy = multi-user.target

Save changes and exit the file.

Start and enable glassfish services.

systemctl start glassfish.service
systemctl enable glassfish.service

Step 5: Add Glassfish ports in Firewall

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

Step 6: Setting up Glassfish Path

Now set Glassfish binaries PATH environment variable using below command

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

Step 7: Set password for Glassfish and enable secure login

By default, Glassfish has no password using below command and set a password for the admin user, Press ENTER 2 times and then type new password

/opt/glassfish5/bin/asadmin --port 4848 change-admin-password

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

/opt/glassfish5/bin/asadmin --port 4848 enable-secure-admin

Now restart Glassfish

systemctl restart glassfish.service

Note: we may unable to access the Glassfish Admin Console after enabling the secure login due to older version of Grizzly module so we will update Grizzly using below commands to access Glassfish admin console.

cd /opt/glassfish5/glassfish/modules/endorsed

mv grizzly-npn-bootstrap.jar grizzly-npn-bootstrap.jar.1

wget https://search.maven.org/remotecontent?filepath=org/glassfish/grizzly/grizzly-npn-bootstrap/1.9/grizzly-npn-bootstrap-1.9.jar -O grizzly-npn-bootstrap.jar

chown glassfish:glassfish grizzly-npn-bootstrap.jar

systemctl restart glassfish.service

Step 8: Accessing Glassfish Server on CentOS / RHEL 8

Finally browse below URL to access Glassfish Admin Console, ignore the certificate warning or install it.


Then, type your login credentials to log in it.

So, this is the Glassfish Admin Console

So, you can read our post about Payara server which is another server.

Finally, share this post with your friends and join our Telegram Channel.

- Advertisement -



Please enter your comment!
Please enter your name here

Donate to Osradar

Latest article