How to Start Glassfish Application Server in Linux using a Command in the Command Line Interface

Posted on

Introduction

This article is focus on the administration of Glassfish Application Server. The administration itself is actually a specific task for starting the Glassfish Application Server. In order to start the Glassfish Application Server in Linux, just fulfill the requirement before. Before going further, there are sevaral part of this article where each part will focus on a specific topic. The first part will focus on the preparation for starting the Glassfish Application Server. The next part which is the main part is focusing on how to start the Glassfish Application Server itself. Finally, the last one has a short mention for checking the process itself.

 

Preparing to Start the Glassfish Application Server

The requirement or the preparation for starting Glassfish Application Server is simple. Just check if the Glassfish Application Server is already exist. In other words, it is the availability of the Glassfish Application Server’s source itself. If it doesn’t exist, just download it. Currently, in the time of the writing of this article, the download link is available in this link. After successfully finish for downloading the source of the Glassfish Application Server where it is normally in the compressed format, extract it first. Put it in any preferable location. In this context of this article, the location is in ‘/opt’.

Starting the Glassfish Application Server

After preparing the Glassfish Application Server, it is the time to run it. In other words, if it exist already, just go to the command line interface to start the Glassfish Application Server. In this context, the process for starting the Glassfish Application Server is done using a specific command. That command is actually running an executable file or a shell script file exist in the source of the Glassfish Application Server. The following is the steps for starting the Glassfish Application Server :

1. Before starting the Glassfish Application Server, in this context, use a suitable user for starting it. Switch to the associated user which is chosen to run the process. Below is the command for switching to that account. For an example, the user with the name of ‘glassfish’ is in charge to run the associated process of Glassfish Application Server. The command execution is :

user@hostname:~$ sudo su - glassfish
[sudo] password for user: 
$ 

2. After successfully switching to the associated account for the Glassfish Application Server which is ‘glassfish’, just start the process already. Before that, don’t forget to connect to the Glassfish Administration Console. Try to connect first by executing the following command :

$ /opt/glassfish4/glassfish/bin/asadmin
Use "exit" to exit and "help" for online help.
asadmin>

3. At last, start the Glassfish Application Server suing the following command :

start-domain

The execution using the above command pattern is available below :

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

Furthermore, the above command for starting the Glassfish Application Server is actually has a one line version of it. That one line consist of a command to just start the Glassfish Application Server without having to access the Glassfish Application Server. Below is the command execution of that version :

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

Checking the Glassfish Application Server

Last but not least, don’t forget to check the Glassfish Application Server. There are several ways for checking the running process. Just execute the following command to check for it :

netstat -tulpn | grep port_number

So, in order to make sure that the process is actually running, execute the above command. The execution of the above command pattern is available as follow :

root@hostname ~# netstat -tulpn | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 19265/java
root@hostname ~#

Choose the right port_number as the parameter to execute the command. In this context, it is using the default password of Glassfish Application Server. The port is ‘8080’. In addition, for checking the process further whether it is actually exist or not, just execute the following command pattern :

ps -aux | grep process_ID

Just execute the above command pattern as follows. Choose the right process ID according to the previous output. The process ID of the running Glassfish Application Server according to the output above is ‘19265’. Therefore, the command execution exist as follows :

root@hostname ~# ps -aux | grep 19265
glassfi+ 19265 0.8 2.1 6260036 352220 pts/35 Sl 16:00 0:18 /usr/lib/jvm/java-8-openjdk-amd64/bin/java -cp /opt/glassfish4/glassfish/modules/glassfish.jar -XX:+UnlockDiagnosticVMOptions -XX:NewRatio=2 -XX:MaxPermSize=192m -Xmx512m -client -javaagent:/opt/glassfish4/glassfish/lib/monitor/flashlight-agent.jar -Djavax.net.ssl.trustStore=/opt/glassfish4/glassfish/domains/domain1/config/cacerts.jks -Dfelix.fileinstall.dir=/opt/glassfish4/glassfish/modules/autostart/ -Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall -Dcom.sun.aas.installRoot=/opt/glassfish4/glassfish -Dfelix.fileinstall.poll=5000 -Djava.endorsed.dirs=/opt/glassfish4/glassfish/modules/endorsed:/opt/glassfish4/glassfish/lib/endorsed -Djava.security.policy=/opt/glassfish4/glassfish/domains/domain1/config/server.policy -Dosgi.shell.telnet.maxconn=1 -Dfelix.fileinstall.bundles.startTransient=true -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory -Dfelix.fileinstall.log.level=2 -Djavax.net.ssl.keyStore=/opt/glassfish4/glassfish/domains/domain1/config/keystore.jks -Djava.security.auth.login.config=/opt/glassfish4/glassfish/domains/domain1/config/login.conf -Dfelix.fileinstall.disableConfigSave=false -Dfelix.fileinstall.bundles.new.start=true -Dcom.sun.aas.instanceRoot=/opt/glassfish4/glassfish/domains/domain1 -Dosgi.shell.telnet.port=6666 -Dgosh.args=--nointeractive -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as -Dosgi.shell.telnet.ip=127.0.0.1 -DANTLR_USE_DIRECT_CLASS_LOADING=true -Djava.awt.headless=true -Djava.ext.dirs=/usr/lib/jvm/java-8-openjdk-amd64/lib/ext:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext:/opt/glassfish4/glassfish/domains/domain1/lib/ext -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver -Djava.library.path=/opt/glassfish4/glassfish/lib:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib com.sun.enterprise.glassfish.bootstrap.ASMain -upgrade false -domaindir /opt/glassfish4/glassfish/domains/domain1 -read-stdin true -asadmin-args --host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=true,,,start-domain,,,--verbose=false,,,--watchdog=false,,,--debug=false,,,--domaindir,,,/opt/glassfish4/glassfish/domains,,,domain1 -domainname domain1 -instancename server -type DAS -verbose false -asadmin-classpath /opt/glassfish4/glassfish/lib/client/appserver-cli.jar -debug false -asadmin-classname com.sun.enterprise.admin.cli.AdminMain
root 24022 0.0 0.0 23960 992 pts/37 S+ 16:34 0:00 grep 19265
root@hostname ~#

Leave a Reply