How to Install and Configure Oracle GlassFish Server 5.1 on Ubuntu, Debian and Linux Mint

 




What is 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 an open-source application server and the reference implementation of Java EE.

GlassFish 5.1 release supports the latest Java Platform: Enterprise Edition 7/8.
It supports Enterprise JavaBeans, JPA, JavaServer Faces, JMS, RMI, JavaServer Pages, servlets, etc.

Install Oracle Java 7/8
Step1 :- sudo apt-get update

Install python-software-properties
Step2 :- sudo apt-get install python-software-properties

add the new repository and install from Oracle Installer
Step3 :- sudo add-apt-repository ppa:webupd8team/java

Install Java 7/8
Step4 :- sudo apt-get install oracle-java7-installer


After installing, confirm the current Java is Oracle version
Step5 :- java –version

Install Glassfish 5.1

Get Glassfish Zip file
Step6 :- wget download.java.net/glassfish/5.1/release/glassfish-5.1.zip

Install unzip first before unpackage to /opt
Step7 :- apt-get install unzip

Create the directory /opt and then unzip the package to /opt:
Step8 :- unzip glassfish-5.1.zip -d /opt

For convenience, add export PATH=/opt/glassfish4/bin:$PATH to the end of ~/.profile.

Start the glassfish server:
Step9 :- asadmin start-domain

A domain is a set of one or more Glassfish Server instances managed by one administration server.
Default Glassfish Server’s port number: 8080.
Default administration Server’s port number: 4848.
Administration User name: admin
Password: none.

In order to visit admin page (yourserverid:4848) remotely, you need to enable secure admin:

Step10 :- asadmin enable-secure-admin

Restart domain to make effect of secure admin:
Step11 :- asadmin restart-domain

Now you can visit admin page (yourserverid:4848) in browser

To stop the GlassFish server:
Step12 :- asadmin stop-domain


Demo service: deploy hello.war on Glassfish

Download the sample application from Glassfish official samples:
Step12 :- wget https://glassfish.java.net/downloads/quickstart/hello.war

Deploy war file:
Step13 :- asadmin deploy /home/ee/glassfish/sample/hello.war

Now you can visit yourserverid:8080/hello

To undeploy the application:
Step14 :- asadmin undeploy hello

In order to save typing "admin user name" and "password" every time you deploy or undeploy an application, create a password file pwdfile with content:

Step15 :- AS_ADMIN_PASSWORD=your_admin_password

Add --passwordfile in command:

Step16 :- asadmin --passwordfile pwdfile deploy /home/ee/glassfish/sample/hello.war

 


0 Comments