What is GlassFish?
GlassFish is an open source Jakarta EE platform application server project started by Sun Microsystems, later sponsored by Oracle Corporation and currently living in the Eclipse Foundation and supported by Payara, Oracle and Red Hat.
In this article, we will describe the installation of GlassFish on Arch Linux operating system.
How to install GlassFish in Arch Linux?
We will explain how to install GlassFish step by step. We will use GlassFish version 6.2.5 in this installation.
Step-1: Install Openjdk
For GlassFish 6.2.5, it is necessary to install the jre17-openjdk package. Therefore, install by specifying the java version in the installation:
[root@arch-linux /]# sudo pacman -S jre17-openjdk
Installation complete, check version:
[root@arch-linux /]# java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment (build 19.0.1+10)
OpenJDK 64-Bit Server VM (build 19.0.1+10, mixed mode)
Step-2: Install required packages for installation
Unzip and wget packages must be installed on the system. If it is installed, you can skip this step.
[root@arch-linux /]# pacman -S wget unzip
resolving dependencies...
looking for conflicting packages...
Packages (2) unzip-6.0-19 wget-1.21.3-1
Total Installed Size: 3.33 MiB
:: Proceed with installation? [Y/n] Y
(2/2) checking keys in keyring [#####################] 100%
(2/2) checking package integrity [#####################] 100%
(2/2) loading package files [#####################] 100%
(2/2) checking for file conflicts [#####################] 100%
(2/2) checking available disk space [#####################] 100%
:: Processing package changes...
(1/2) installing wget [#####################] 100%
Optional dependencies for wget
ca-certificates: HTTPS downloads [installed]
(2/2) installing unzip [#####################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
Step-3: Download .zip Package and Extract
Go to Eclipse's GlassFish download page.
Right click on the zip file of the version you want to download and copy the link address.
Type this link after the wget command:
[root@arch-linux /]# wget https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.5.zip
--2022-10-30 20:23:46-- https://download.eclipse.org/ee4j/glassfish/glassfish-6.2.5.zip
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving download.eclipse.org (download.eclipse.org)... 198.41.30.199
Connecting to download.eclipse.org (download.eclipse.org)|198.41.30.199|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 118284616 (113M) [application/zip]
Saving to: ‘glassfish-6.2.5.zip’
glassfish-6.2.5.zip 5%[> ] 6.07M 745Kglassfish-6.2.5.zi glassfish-6.2.5.zip 100%[=============================>] 112.80M 2.02MB/s in 1m 56s
2022-10-30 20:25:43 (993 KB/s) - ‘glassfish-6.2.5.zip’ saved [118284616/118284616]
Extract the downloaded file with unzip:
[root@arch-linux /]# unzip glassfish-6.2.5.zip
Move the file under the opt directory:
[root@arch-linux /]# mv glassfish6 /opt/
Define the PATH variable:
[root@arch-linux /]# echo "export PATH=$PATH:/opt/glassfish6/bin" >> ~/.bashrc [root@arch-linux /]# source ~/.bashrc
Step-4: Start GlassFish Server
Note: If you have not defined a PATH, you need to go to "/opt/glassfish6/bin/"and write "./" at the beginning of the commands to run the commands below.
[root@arch-linux opt]# cd /opt/glassfish6/bin/ ./asadmin start-domain
3 parameters are used to manage GlassFish as a service:
- start-domain
- stop-domain
- list-domains
To start GlassFish:
[root@arch-linux bin]# asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain Location: /opt/glassfish6/glassfish/domains/domain1
Log File: /opt/glassfish6/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
To stop GlassFish:
[root@arch-linux bin]# asadmin stop-domain
Waiting for the domain to stop .
Command stop-domain executed successfully.
To list GlassFish domains:
[root@arch-linux bin]# asadmin list-domains
domain1 running
Command list-domains executed successfully.
Initially, a password is not defined for the admin user. To define a password:
[root@arch-linux bin]# asadmin 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.
Proceed to the "Enter the admin password" question without entering any password, define a new password.
Finally, enable the secure admin login:
[root@arch-linux bin]# asadmin --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.
After this step, stop and start the active domain.
[root@arch-linux bin]# asadmin stop-domain [root@arch-linux bin]# asadmin start-domain
Step-5: Creating Systemd Service for GlassFish
Create glassfish.service file under /usr/lib/systemd/system directory:
[root@arch-linux glassfish7]# nano /usr/lib/systemd/system/glassfish.service
Define the following information in the glassfish.service file:
[Unit] Description = GlassFish Server v6.2.5 After = syslog.target network.target [Service] 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 [Install] WantedBy = multi-user.target
Reload services:
[root@arch-linux bin]# systemctl daemon-reload
Start and enable:
[root@arch-linux bin]# systemctl start glassfish
[root@arch-linux bin]# systemctl enable glassfish
Created symlink /etc/systemd/system/multi-user.target.wants/glassfish.service → /usr/lib/systemd/system/glassfish.service.
Service status:
[root@arch-linux bin]# systemctl status glassfish
[root@arch-linux bin]# systemctl status glassfish
● glassfish.service - GlassFish Server v6.2.5
Loaded: loaded (/usr/lib/systemd/system/glassfish.service; enabled; preset: disabled)
Active: active (running) since Sun 2022-10-30 20:41:03 UTC; 22min ago
Process: 3690 ExecStart=/usr/bin/java -jar /opt/glassfish6/glassfish/lib/client/appserver>
Main PID: 3713 (java)
Tasks: 91 (limit: 2352)
Memory: 473.7M
CPU: 28.309s
CGroup: /system.slice/glassfish.service
└─3713 /usr/lib/jvm/java-17-openjdk/bin/java -cp /opt/glassfish6/glassfish/modul>
Oct 30 20:41:00 arch-linux systemd[1]: Starting GlassFish Server v6.2.5...
Oct 30 20:41:03 arch-linux java[3690]: Waiting for domain1 to start ...
Oct 30 20:41:03 arch-linux java[3690]: Successfully started the domain : domain1
Oct 30 20:41:03 arch-linux java[3690]: domain Location: /opt/glassfish6/glassfish/domains/do>
Oct 30 20:41:03 arch-linux java[3690]: Log File: /opt/glassfish6/glassfish/domains/domain1/lo>
Oct 30 20:41:03 arch-linux java[3690]: Admin Port: 4848
Oct 30 20:41:03 arch-linux java[3690]: Command start-domain executed successfully.
Oct 30 20:41:03 arch-linux systemd[1]: Started GlassFish Server v6.2.5.
Step-6: Login GlassFish Server
To login to GlassFish Server, access is provided in the web browser with https://ip_address:4848. Login with the password you defined to the admin user in the console:
Installation completed successfully.
Summary
Since GlassFish continues to be developed by the Eclipse Foundation, we have described the installation with the most recent version.
You can get help from the following command for what you can do with the asadmin command in the operations you will do from the terminal:
[root@arch-linux ~]# asadmin -?
NAME
asadmin - utility for performing administrative tasks for Oracle
GlassFish Server
SYNOPSIS
asadmin [--host host]
[--port port]
[--user admin-user]
[--passwordfile filename]
[--terse={true|false}]
[--secure={false|true}]
[--echo={true|false}]
[--interactive={true|false}]
[--detach={true|false}]
[--help]
[subcommand [options] [operands]]
...
For GlassFish basic features, you can visit https://glassfish.org.
References
glassfish.org - Installing Eclipse GlassFish Server 5.1