Glassfish installation in Linux

0
172

GlassFish

GlassFish is an open-source application server project started by Sun Microsystems for the Java EE platform and now sponsored by Oracle Corporation. The supported version is called Oracle GlassFish Server. GlassFish is free software, dual-licensed under two free software licences: the Common Development and Distribution License (CDDL) and the GNU General Public License (GPL) with the classpath exception.

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.

JAVA Installation

First Change the directory to where the Java to be installed.

[root@localhost ~]# cd /opt/
[root@localhost opt]#wget http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
[root@localhost opt]#tar xzf jdk-8u91-linux-x64.tar.gz
[root@localhost opt]# cd jdk1.8.0_91/
[root@localhost jdk1.8.0_91]# alternatives --install /usr/bin/java java /opt/jdk1.8.0_91/bin/java 2
[root@localhost jdk1.8.0_91]# alternatives --config java

There are 4 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1      /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.101-2.6.6.1.el7_2.x86_64/jre/bin/java
*  2      /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.91-0.b14.el7_2.x86_64/jre/bin/java
 + 3      /opt/jdk1.7.0_79/bin/java
   4      /opt/jdk1.8.0_91/bin/java

Enter to keep the current selection[+], or type selection number: 4
[root@localhost jdk1.8.0_91]#java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
[root@localhost jdk1.8.0_91]#alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_91/bin/jar 2
[root@localhost jdk1.8.0_91]#alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_91/bin/javac 2
[root@localhost jdk1.8.0_91]#alternatives --set jar /opt/jdk1.8.0_91/bin/jar
[root@localhost jdk1.8.0_91]#alternatives --set javac /opt/jdk1.8.0_91/bin/javac
[root@localhost jdk1.8.0_91]#export JAVA_HOME=/opt/jdk1.8.0_91
[root@localhost jdk1.8.0_91]#export JRE_HOME=/opt/jdk1.8.0_91/jre
[root@localhost jdk1.8.0_91]#export PATH=$PATH:/opt/jdk1.8.0_91/bin:/opt/jdk1.8.0_91/jre/bin

Glassfish Installation

We can Download the Glassfish from their official site by uisng the following command

[root@localhost ~]#wget http://download.java.net/glassfish/4.1.1/release/glassfish-4.1.1.zip

Once the Download completed successfully, extract it by using tar command as follows

[root@localhost ~]#unzip glassfish-4.1.1*zip

Start the GlassFish server by using the following command as follows

[root@localhost ~]#glassfish4/bin/asadmin start-domain

We can access the glass fish web-interface by using the url: http://localhost:4848. The default user name is ‘admin’ and the password is blank.

Glassfish login error

When you try to login the above window will be opened with error “Secure Admin must be enabled to access the DAS remotely”. To avoid this we have to configure the secure admin access as follows

Open the glass fish installed path and run the command as follows

[root@localhost bin]#./asadmin
Use "exit" to exit and "help" for online help.
 
asadmin> change-admin-password
 
Enter admin user name [default: admin]>admin
Enter the admin password>
Enter the new admin password> [enter your new password]
Enter the new admin password again> [enter your new password again]
Command change-admin-password executed successfully.

Now enable secure admin access run the command as follows

Use "exit" to exit and "help" for online help.
 
asadmin> change-admin-password
 
Enter admin user name [default: admin]>admin
Enter the admin password>
Enter the new admin password> [enter your new password]
Enter the new admin password again> [enter your new password again]
Command change-admin-password executed successfully.

asadmin>list-file-users --authrealmname admin-realm
...
admin
Command list-file-users executed successfully.
 
asadmin> exit
Command multimode executed successfully.

Now we are able to login to Glassfish admin panel.

login screen

The Default username admin and password is changed password. After login we get the homepage

glshfish home page

Now create a systemd service for glassfish server create a file under the name glassfish.service in /etc/systemd/system directory.

[Unit]
Description = GlassFish Server v4.1
After = syslog.target network.target
 
[Service]
User=glassfish
ExecStart = /opt/java -jar /root/glassfish4/glassfish/lib/client/appserver-cli.jar start-domain
ExecStop = /opt/java -jar /root/glassfish4/glassfish/lib/client/appserver-cli.jar stop-domain
ExecReload = /opt/java -jar /root/glassfish4/glassfish/lib/client/appserver-cli.jar restart-domain
Type = forking
 
[Install]
WantedBy = multi-user.target

Now enable glassfish service by using the following command

#systemctl enable glassfish.service

We can access Glassfish web page at http://ipaddress:8080. Enjoy Glassfish.

Comments

comments