Get started with GlassFish
This guide will lead you to install GlassFish, start it and run your applications with it.
Introduction
Eclipse Glassfish is a server for developing and running enterprise and web applications based on Jakarta EE and MicroProfile. GlassFish is developed through the opensource community project at the Eclipse Foundation. The Eclipse GlassFish project provides a structured process for developing the GlassFish platform faster, while maintaining the most important feature of Jakarta EE: compatibility with older versions.
This guide will get you started with GlassFish, from downloading GlassFish to running an application on it.
Requirements
Before installation, you should make sure that you meet the following minimum requirements
- Required JDK Versions : Eclipse GlassFish Release 7 requires Java 11 or newer. It’s tested on Java 17 and Java 21.
- Required Disk Space : The download sizes for Eclipse GlassFish 7 vary depending on the package you choose. The following are the approximate sizes of the ZIP packages for the Full and Web profiles:
- Full *.zip: 114 MB (136 MB unzipped)
- Web *.zip: 64.9 MB (82.9 MB unzipped) The installation sizes will vary depending on your configuration, but the approximate amount of disk space used by Eclipse GlassFish 7 is as follows:
- Full: 138 MB
- Web: 84.4 MB
- Required Free Ports : You must have sixteen unused ports available for the ports Eclipse GlassFish uses. The installation program automatically detects ports that are in use and suggests currently unused ports for the default settings. The initial default port assignments are listed in the following table. If these default port numbers are in use, the installation program assigns a randomly selected port number from the dynamic port range. The selected port number might not be the next available port number.
- You can find the list of default port assignments in GlassFish in the Configuration Reference section at the end of this guide.
In some situations, such as when multiple domains are running on a single host, port conflicts can arise in the auto-generated ports used by Message Queue and the GMS. To avoid these conflicts, you can configure the JMS host and the GMS to use specific ports.
- Message Queue Broker Requirements: Eclipse GlassFish 7 is now bundled with Message Queue (MQ) Broker 5.1.1. Refer to the Open Message Queue Release Notes for complete information about MQ Broker requirements.
- Paths and Environment Settings for the JDK Software: Ensure that your JDK configuration settings on all local and remote Eclipse GlassFish hosts adhere to the guidelines listed below. Failure to adhere to these guidelines can cause various problems that may be difficult to trace. The following topics are addressed here:
Download
The latest version of Eclipse Glassfish is availaible for download on the Glassfish website.
Installation
Installation files for Eclipse GlassFish are available for download from the Eclipse GlassFish Downloads page.
When downloading GlassFish, you can choose from two variants:
- Eclipse GlassFish, Jakarta EE Platform – this variant contains all the features of GlassFish Server, including full Jakarta EE Platform, and supported MicroProfile APIs
- Eclipse GlassFish, Jakarta EE Web Profile – this variant of GlassFish Server contains Jakarta EE Web Profile, a subset of Jakarta EE Platform. It doesn’t contain MicroProfile APIs. It contains all other features of the GlassFish Server
The download page also offers the same two variants for Eclipse GlassFish Embedded, which is a version of GlassFish that can be started and configured from a Java application using Java APIs. GlassFish Embedded provides the same features as GlassFish Server, except some enterprise features like clustering and administration console. It’s used differently than GlassFish Server. This guide only describes how to use the GlassFish server, it doesn’t explain how to use GlassFish Embedded.
Installing Eclipse GlassFish Using the ZIP File
- After download the ZIP file, change to the directory where you downloaded the ZIP file.
- Unzip the file.
- Mac OS X, Linux, and Unix-like systems:
- >
unzip zip-file-name
zip-file-name
is the name of the file that you downloaded. For example:glassfish-7.0.13.zip
- >
- Windows systems:
- Unzip using your favorite file compression utility. Eclipse GlassFish 7 is extracted into a new glassfish7 directory under your current directory. This glassfish7 directory is referred to throughout the Eclipse GlassFish documentation set as
as-install-parent
.
- Unzip using your favorite file compression utility. Eclipse GlassFish 7 is extracted into a new glassfish7 directory under your current directory. This glassfish7 directory is referred to throughout the Eclipse GlassFish documentation set as
You can now continue to using GlassFish with your favorite Java IDE:
For using GlassFish without an IDE, continue with the next sections in this guide.
Starting GlassFish and Configuration
Starting and Stopping the Server
When you install Eclipse GlassFish, it contains the default configuration section (called domain in GlassFish) with the name name domain1
. The following procedures describe how to start and stop GlassFish with this domain1
configuration when it is the only domain configured.
Start GlassFish with the Default Domain
Run GlassFish in foreground, with the startserv
command and the default domain1
configuration:
as-install/bin/startserv
You can also run GlassFish in the background, with the asadmin start-domain
command:
as-install/bin/asadmin start-domain
The command starts the server with the default domain configuration, domain1
.
Stop GlassFish
Run the stopserv
command or asadmin stop-domain
command without an arguments:
as-install/bin/stopserv
The command stops the server with the default domain configuration, domain1
.
In older GlassFish versions, the stopserv command is present in glassfish/bin directory only: as-install/glassfish/bin/stopserv
. You can also stop the server with as-install/bin/asadmin stop-domain
.
To determine whether the server is running (with the domain1
configuration), use the asadmin list-domains
command:
as-install/bin/asadmin list-domains
Starting the Administration Console
The Eclipse GlassFish Administration Console provides a browser interface for configuring, administering, and monitoring GlassFish. When you have GlassFish server running, you can access it in the following way:
- Type the Admin Console URL in your browser. Admin Console is exposed on port 4848 by default. The default URL for the Administration Console on the local host is as follows: http://localhost:4848.
Running applications
Deploying Applications
The process of configuring and enabling applications to run within the Eclipse GlassFish framework is referred to as deployment. This section explains how to deploy (run), list, and undeploy (stop) applications. The procedures in this section use the hello.war
sample application, that you can download from here:
GlassFish server must be running before you deploy the sample application.
Using command line
To deploy the application using command line, follow these instructions:
- Run the asadmin deploy command. The general form for the command is as follows:
as-install/bin/asadmin deploy war-name
- To deploy the
hello.war
sample, the command is as follows:as-install/bin/asadmin deploy sample-dir/hello.war2
–
- To deploy the
- Access the hello application by typing the following URL in your browser: http://localhost:8080/hello
- The application’s start page is displayed, and you are prompted to type your name:
Hi, my name is Duke. What's yours?
- Type your name and click Submit. The application displays a customized response, giving you a personal Hello.
- To List Deployed Applications From the Command Line, run the
asadmin list-applications
command:as-install/bin/asadmin list-applications
To Undeploy the Sample Application From the Command Line:
- Run the asadmin undeploy command. The general form for the command is as follows:
as-install/bin/asadmin undeploy application-name
- For the sample application
hello.war
, use the text “hello”, not the file name “hello.war”. The name of the application is derived from the file name but doesn’t contain the “war” extension. You can see the name of the application in the output of the list-applications command. For the hello.war example application, the command is as follows:as-install/bin/asadmin undeploy hello
- For the sample application
Using the Administration Console
To deploy the application using the Administration Console, follow below instructions:
- Launch the Administration Console by typing the following URL in your browser: http://localhost:4848
- Click the Applications node in the tree on the left.
- Click the Deploy button.
- Select “Packaged File to be Uploaded to the Server”, and click Browse.
- Navigate to the location in which you saved the hello.war sample, select the file, and click Open. You are returned to the Deploy Applications or Modules page
- Specify “hello” in the “Context Root” field – this specifies that the application will be available at http://localhost:8080/hello
- Accept the other default settings, and click OK. You are returned to the Applications page.
- In the row for the “hello” application, click the “Launch” link in the “Action” column to access the application. This opens a new window with all the links where the application is available. Click one of the links to access the application. The application will be available at http://localhost:8080/hello/, although the links in the Administration console may contain name of your computer instead of “localhost”.
To Undeploy the Sample Application by Using the Administration Console:
- Launch the Administration Console by typing the following URL in your browser: http://localhost:4848
- Click the “Applications” node in the tree on the left.
- Select the check box next to the hello sample application.
- Remove or disable the application.
- To remove the application, click the Undeploy button. This will stop the application and remove it from the server completely
- To disable the application, click the Disable button. This will stop the application. It will stay in the server and it will be possible to enable (start) it again
Deploying and Undeploying Automatically from the filesystem
Eclipse GlassFish enables you to performing the following deployment-related tasks automatically, just by copying or deleting the application file.
You can deploy applications automatically by placing them in the domain-dir/autodeploy
directory, where domain-dir
is the directory of the domain for which you want to configure automatic deployment. For this example, use the default domain, domain1
, in the default directory which is as-install/domains
: as-install/domains/domain1/autodeploy
To deploy the sample application on Linux, Mac OS X or other Unix-like systems, type this command: cp sample-dir/hello.war as-install/domains/domain-dir/autodeploy
On Windows systems, type this command: copy sample-dir\hello.war as-install\domains\domain-dir\autodeploy
GlassFish automatically discovers and deploys the application. The default URL for the application is as follows: http://localhost:8080/hello/. This time, you don’t configure the context root of the URL, it is derived from the name of the WAR file or it is defined in a configuration file inside the WAR file.
To Undeploy the Sample Application Automatically
- Change to the autodeploy directory:
cd as-install/domains/domain1/autodeploy
- Delete the sample application’s WAR file to undeploy and remove the application.
- On Linux, Mac OS X, or other Unix-like systems, type this command:
rm hello.war
- On Windows systems, type this command:
del hello.war
- On Linux, Mac OS X, or other Unix-like systems, type this command:
GlassFish configuration reference
Default port assignments
The following table lists all the network listeners opened by GlassFish and their default port numbers:
Default Ports | Listener description |
---|---|
4848 | Administration Console (also for Admin and Monitoring REST interfaces) |
8080 | HTTP |
8181 | HTTPS |
8686 | JMX service |
3700 | IIOP |
3820 | IIOP/SSL |
3920 | IIOP/SSL with mutual authentication |
22 | SSH port |
9009 | Java debugger |
7676 | JMS provider |
Auto-generated from the operating system’s dynamic port range | Message Queue TCP port |
Auto-generated from the operating system’s dynamic port range | Message Queue Admin port |
9090 | GMS TCP start port |
9200 | GMS TCP end port |
Auto-generated between GMS TCP start and end ports | GMS listener port |
Auto generated between 2048 and 49151 | GMS multicast port |
Default Paths and File Names
The following table describes the default paths and file names that are used in this guide.
Placeholder | Description | Default Value |
---|---|---|
as-install | Represents the base installation directory for Eclipse GlassFish. | Installations on Linux, Mac OS, and Unix-like systems: user’s-home-directory/glassfish7/glassfish. Installations on Windows : SystemDrive:\glassfish7\glassfish |
as-install-parent | Represents the parent of the base installation directory for Eclipse GlassFish. | Installations on Linux, Mac OS, and Unix-like systems:: user’s-home-directory/glassfish7. Installations on Windows: SystemDrive:\glassfish7 |
domain-root-dir | Represents the directory in which a domain is created by default. | as-install/domains/ |
domain-dir | Represents the directory in which a domain’s configuration is stored. | domain-root-dir/<domain-name> |
instance-dir | Represents the directory for a server instance. | domain-dir/<instance-name> |
Default Administration Values
The following table lists default administration values for Eclipse GlassFish:
Description | Default Value or Location |
---|---|
Domain name | domain1 |
Master password | changeit |
asadmin command-line utility | as-install/bin/asadmin |
Configuration files | domain-dir/config |
Log files | domain-dir/logs |