/ Linux

Glassfish

Glassfish 3

Installation

CentOS 7

useradd glassfish3 -d /opt/glassfish3
passwd glassfish3
yum install -y wget unzip bash-completion java-1.6.0-openjdk 
wget http://download.oracle.com/glassfish/v3.0.1/release/glassfish-3.0.1.zip
unzip glassfish-3.0.1.zip -d /opt/glassfish3

Java & path

cat >> /opt/glassfish3/.bash_profile <<EOF
# Java
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/
export PATH=$JAVA_HOME/bin:$PATH
# Glassfish
export PATH=$HOME/glassfish/bin:$PATH
EOF

Service

cat >> /etc/systemd/system/glassfish3.service <<EOF
[Unit]
Description = GlassFish Server v3
After = syslog.target network.target

[Service]
User=glassfish3
ExecStart = /opt/glassfish3/glassfish/bin/asadmin start-domain
ExecStop = /opt/glassfish3/glassfish/bin/asadmin stop-domain
ExecReload = /opt/glassfish3/glassfish/bin/asadmin restart-domain
Type = forking

[Install]
WantedBy = multi-user.target
EOF

Enable & start

systemctl daemon-reload
systemctl enable glassfish3
systemctl start glassfish3
systemctl status glassfish3

Output

[root@resopaappli01 opt]# systemctl status glassfish3.service
● glassfish3.service - GlassFish Server v3
   Loaded: loaded (/etc/systemd/system/glassfish3.service; enabled; vendor preset: disabled)
   Active: active (running) since ven. 2016-07-22 14:51:18 CEST; 4min 58s ago
 Main PID: 42688 (java)
   CGroup: /system.slice/glassfish3.service
           └─42688 /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.39.x86_64/jre/bin/java -cp /opt/glassfish3/glassfish/modules/glassfish.jar -XX:+UnlockDiagnosticVMOptions -XX:MaxPermSize=192m -XX:NewRatio=2 -XX:+LogVMOutput -XX:LogFile=/opt/g...

juil. 22 14:51:14 resopaappli01 systemd[1]: Starting GlassFish Server v3...
juil. 22 14:51:17 resopaappli01 asadmin[42673]: Waiting for DAS to start ...
juil. 22 14:51:17 resopaappli01 asadmin[42673]: Started domain: domain1
juil. 22 14:51:17 resopaappli01 asadmin[42673]: Domain location: /opt/glassfish3/glassfish/domains/domain1
juil. 22 14:51:17 resopaappli01 asadmin[42673]: Log file: /opt/glassfish3/glassfish/domains/domain1/logs/server.log
juil. 22 14:51:17 resopaappli01 asadmin[42673]: Admin port for the domain: 4848
juil. 22 14:51:17 resopaappli01 asadmin[42673]: Command start-domain executed successfully.
juil. 22 14:51:18 resopaappli01 systemd[1]: Started GlassFish Server v3.

Firewall

firewall-cmd --permanent --add-port 8080/tcp
firewall-cmd --permanent --add-port 4848/tcp

Test

[root@resopaappli01 opt]# curl -sL http://localhost:8080 | grep -i glassfish
<title>GlassFish Server 3.0.1 - Server Running</title>

Administration

Just notes, untested

Enable admin (http://server:4848)

su - glassfish3
asadmin 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.
asadmin restart-domain

Deploy demo

wget https://glassfish.java.net/downloads/quickstart/hello.war
asadmin deploy /home/ee/glassfish/sample/hello.war
  Enter admin user name>  admin
  Enter admin password for user "admin"> 
  Application deployed with name hello.
  Command deploy executed successfully.

Undeploy

asadmin undeploy hello
  Enter admin user name>  admin
  Enter admin password for user "admin"> 
  Command undeploy executed successfully.

No password prompt

echo "AS_ADMIN_PASSWORD=your_admin_password" >> ~/.glassfish_passwd
chmod 400 ~/.glassfish_passwd
echo "alias asadmin='asadmin --passwordfile ~/.glassfish_passwd'" >> ~/.bash_profile
Glassfish
Share this