Skip to content

Java EE GlassFish application server

alejandrort edited this page Jun 26, 2019 · 6 revisions

GlassFish is the reference implementation of Java EE platform and as such supports Enterprise JavaBeans (EJBs), Java Persistence Architecture (JPA), JavaServer Faces (JSF), Java Message Service (JMS), JavaServer Pages (JSP), and Servlets.

Download

We will work with GlassFish 5 supporting Java EE 8, and the distribution can be found in Eclipse Glassfish Downloads tab. Specifically, download the Eclipse GlassFish 5.1.0.

Installation

For a more comfortable usage of GlassFish, we will create an environment variable that makes it possible to run glassfish related commands directly in a terminal - similar as we did with Java and Maven.

Windows

It is strongly recommended to decompress the GlassFish 5 file under C: directory

In the same way as you added the Java and Maven environment variables, add a GLASSFISH_HOME variable and set the value to the path C:\glassfish5.

Also, add this variable to PATH, as %GLASSFISH_HOME%\bin. The figures below show how to add the environment variable.

There was an error with the image

There was an error with the image

Ubuntu Linux and MacOS

It is strongly recommended to decompress the GlassFish 5 file under /opt directory

Update the PATH environment variable to include the bin folder of the GlassFish installation

export PATH=/opt/glassfish5/bin:$PATH

To update the current session:

source ~/.profile

or

source ~/.bashrc

Now GlassFish should be properly configured and we should be able to run commands.

Validation

To run the GlassFish application server execute

asadmin start-domain

The output should be similar to

Waiting for domain1 to start ...................

Successfully started the domain : domain1

domain Location: /opt/glassfish5/glassfish/domains/domain1

Log File: /opt/glassfish5/glassfish/domains/domain1/logs/server.log

Admin Port: 4848

Command start-domain executed successfully.

Now the application server is up and running, and the administration console is available via http://localhost:4848 which should open a admin page similar to

There was an error with the image

To stop the application server, execute the command

asadmin stop-domain.

The result expected if the domain is successfully stoped is shown below

Waiting for the domain to stop ..

Command stop-domain executed successfully.