Introduction
This article shows how to connect to Glassfish Administration Console using a command line. So, in other words, the connection to the Glassfish Administration Console occurs in the command line interface. It is very easy to connect to the Glassfish Administratoin Console in a command line interface using a specific command. The following is an example for connecting to the Glassfish Administration Console by performing several steps consisting of several parts. The first part is the preparation for checking the service status. The next part is for the actual connection to the Glassfish Administration Console itself.
Preparation for Checking the Glassfish Application Server Status
1. Make sure that the Glassfish service is available and it is running properly to accept incoming requmeest or incoming connection. In order to make sure of it, check it by performing the following command. The first command is to check if there is a port listening for an incoming request. By default, Glassfish Application Server runs using port 8080. So, the folowing is the command pattern :
netstat -tulpn | grep port_number
The execution of the above command pattern exist below :
root@hostname ~# netstat -tulpn | grep 8080 tcp6 0 0 :::8080 :::* LISTEN 4465/java root@hostname ~#
According to the output of the above command, there is a process running to listen any incoming requests in port 8080. So, check the process whether it is actually running or not using the second command. The pattern for that command exists below :
ps aux | grep process_id
The command execution of the above pattern is in the following output :
root@hostname ~# ps aux | grep 4465
root@hostname ~# ps aux | grep 4465 glassfi+ 4465 48.1 2.1 6273020 349476 pts/22 Sl 22:51 0:17 /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 4641 0.0 0.0 23960 1008 pts/22 S+ 22:51 0:00 grep 4465 root@hostname ~#
Fortunately, there is a process running assoiated with the Glassfish Application Server. It exist as it shows in the output above where it runs with the Process ID of 4465.
2. So, since it is a process running and it is ready to accept any incoming request on port 8080, don’t forget to check the Glassfish Administration Console port. It listens on a different port which is on port 4848 by default. The following is the process for checking the status of that port :
root@hostname ~# netstat -tulpn | grep 4848rea tcp6 0 0 :::4848 :::* LISTEN 4465/java You have new mail in /var/mail/root root@hostname ~# ps aux | grep
There is no need to check the process further. The reason is because the process handling the port for listening any incoming request on port 8080 as the application server with the one on port 4848 as the management server is actually the same process.
Connection to the Glassfish Administion Console via Command Line Interface
3. Connect to the Glassfish Administration Console as follows :
root@hostname ~# su - glassfish $ /opt/glassfish4/glassfish/bin/asadmin Use "exit" to exit and "help" for online help. asadmin>
In Unix or Linux operating system family, just by executing the ‘asadmin’ script where it exists in the binary folder of the Glassfish Application Server’s source installation, the connection to the Glassfish Administration Console via command line interface is a success.