GlassFish Server 4.0 Quick Start Guide
GlassFish Server provides a server for the development and deployment of Java Platform, Enterprise Edition (Java EE platform) applications and web technologies based on Java technology. GlassFish Server 4.0 provides the following:
A lightweight and extensible core based on OSGi Alliance standards
A web container
An easy-to-use Administration Console for configuration and management
Update Tool connectivity for updates and add-on components
The following topics are addressed here:
About This Quick Start Guide
This Quick Start Guide demonstrates key features of GlassFish Server and enables you to quickly learn the basics. Step-by-step procedures introduce you to product features and enable you to use them immediately.
This guide assumes that you have already obtained and installed the GlassFish Server 4.0 software. For more information about installing GlassFish Server 4.0, see the Installation Guide.
Instructions and examples in this guide that apply to all supported operating systems use the forward slash character (/
) as path separators in all file names and commands. Ensure that you use the correct character for the system on which GlassFish Server is installed. For example:
UNIX, Linux, or Mac OS X systems: as-install
/bin/asadmin
Windows systems: as-install
\bin\asadmin
This guide provides basic information only. For comprehensive information about GlassFish Server and other entities mentioned in this guide, see For More Information.
To review additional details about this release before you begin using the software, see the Release Notes. The Release Notes provide important information about the GlassFish Server 4.0 release, including details about new features, information about known issues and possible workarounds, and tips for installing and working with GlassFish Server 4.0 software.
Default Paths and File Names
The following table describes the default paths and file names that are used in this book.
Table 1-1 Default Paths and File Names
Placeholder | Description | Default Value |
---|---|---|
as-install |
Represents the base installation directory for GlassFish Server. In configuration files, as-install is represented as follows:
|
Installations on the Oracle Solaris operating system, Linux operating system, and Mac OS operating system: user's-home-directory Installations on the Windows operating system: SystemDrive |
as-install-parent |
Represents the parent of the base installation directory for GlassFish Server. |
Installations on the Oracle Solaris operating system, Linux operating system, and Mac operating system: user's-home-directory Installations on the Windows operating system: SystemDrive |
domain-root-dir |
Represents the directory in which a domain is created by default. |
as-install |
domain-dir |
Represents the directory in which a domain's configuration is stored. In configuration files, domain-dir is represented as follows:
|
domain-root-dir |
instance-dir |
Represents the directory for a server instance. |
domain-dir |
Default Administration Values
The following table lists default administration values for GlassFish Server. See Default Paths and File Names for more information about the as-install and domain-dir placeholders.
Table 1-2 Default Administration Values
Item | Default Value or Location |
---|---|
Domain name |
|
Master password |
|
|
as-install |
Configuration files |
domain-dir |
Log files |
domain-dir |
Administration server port |
|
HTTP port |
|
HTTPS port |
|
Pure JMX clients port |
|
Message Queue port |
|
IIOP port |
|
IIOP/SSL port |
|
IIOP/SSL port with mutual authentication |
|
Starting and Stopping the Default Domain
When you install GlassFish Server, a default domain named domain1
is created. The following procedures describe how to start and stop domain1
when it is the only domain. For information about starting and stopping a domain when there are multiple domains, see Administering Domains, in Oracle GlassFish Server Administration Guide.
To Start the Default Domain
Before You Begin
GlassFish Server software must be installed before you start the domain.
Run the asadmin start-domain
command without an operand:
as-install/bin/asadmin start-domain
The command starts the default domain, domain1
.
To Stop the Default Domain
Run the asadmin stop-domain
command without an operand:
as-install/bin/asadmin stop-domain
The command stops the default domain, domain1
.
Tip:
To determine whether a domain is running, use the asadmin list-domains
command:
as-install/bin/asadmin list-domains
Starting and Stopping the Database Server
A database server is not started by default when you start the GlassFish Server domain. If your applications require a database back end, you must start and stop the database server manually.
The following procedures describe how to start and stop the Java DB server that is bundled with GlassFish Server. For information about starting and stopping other database servers, see the documentation for your specific product.
For the list of database products supported in this release, see the Release Notes.
For more information about database connectivity, see Administering Database Connectivity, in Oracle GlassFish Server Administration Guide.
To Start the Java DB Server
Before You Begin
At least one GlassFish Server domain must be started before you start the database server.
Run the asadmin start-database
command.
The general form for the command is as follows:
as-install/bin/asadmin start-database --dbhome directory-path
For example, to start the Java DB server from its default location:
as-install/bin/asadmin start-database --dbhome as-install-parent/javadb
To Stop the Java DB Server
Run the asadmin stop-database
command:
as-install/bin/asadmin stop-database
Starting the Administration Console
The GlassFish Server Administration Console provides a browser interface for configuring, administering, and monitoring GlassFish Server.
To Start the Administration Console
Before You Begin
At least one GlassFish Server domain must be started.
Type the URL in your browser.
The default URL for the Administration Console on the local host is as follows:
http://localhost:4848
If prompted, log in to the Administration Console.
You will be prompted to log in if you chose to require an administration password at the time GlassFish Server was installed.
See Also
For more information, see the Administration Console online help.
Deploying and Undeploying Applications
The process of configuring and enabling applications to run within the GlassFish Server framework is referred to as deployment.
This section explains how to deploy, list, and undeploy applications. The procedures in this section use the hello.war
sample application. The following topics are addressed here:
Deploying and Undeploying the Sample Application From the Command Line
Deploying and Undeploying Applications by Using the Administration Console
Deploying and Undeploying the Sample Application Automatically
To Obtain the Sample Application
Download a copy of the
hello.war
sample application fromhttp://glassfish.java.net/downloads/quickstart/hello.war
.Save the
hello.war
file in the directory of your choice.This directory is referred to as sample-dir.
Deploying and Undeploying the Sample Application From the Command Line
GlassFish Server provides asadmin
subcommands for performing the following deployment-related tasks:
To Deploy the Sample Application From the Command Line
Before You Begin
The sample application must be available before you start this task. To download the sample, see To Obtain the Sample Application. At least one GlassFish Server domain must be started before you deploy the sample application.
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.warAccess 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
.
See Also
For more information about the deploy
subcommand, see deploy
(1).
For more information about deploying applications from the command line, see Oracle GlassFish Server Application Deployment Guide.
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 war-name
For war-name, use the literal hello
, not the full hello.war
name.
For the hello.war
example, the command is as follows:
as-install/bin/asadmin undeploy hello
See Also
For more information about the undeploy
subcommand, see undeploy
(1).
Deploying and Undeploying Applications by Using the Administration Console
The graphical Administration Console of GlassFish Server enables you to perform the following deployment-related tasks:
To Deploy the Sample Application by Using the Administration Console
To Undeploy the Sample Application by Using the Administration Console
To Deploy the Sample Application by Using the Administration Console
Before You Begin
The sample application must be available before you start this task. To download the sample, see To Obtain the Sample Application. At least one GlassFish Server domain must be started before you deploy the sample application.
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.
The Applications page is displayed.
Click the Deploy button.
The Deploy Applications or Modules page is displayed.
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 a description in the Description field, for example:
hello
Accept the other default settings, and click OK.
You are returned to the Applications page.
Select the check box next to the
hello
application and click the Launch link to run the application.The default URL for the application is as follows:
http://localhost:8080/hello/
See Also
For more information, see the Administration Console online help.
To View Deployed Applications in 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.
Expand the node to list deployed applications. Deployed applications are also listed in the table on the Applications page.
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.
The Applications page is displayed.
Select the check box next to the
hello
sample application.Remove or disable the application.
To remove the application, click the Undeploy button.
To disable the application, click the Disable button.
See Also
For more information, see the Administration Console online help.
Deploying and Undeploying the Sample Application Automatically
GlassFish Server enables you to performing the following deployment-related tasks automatically:
To Deploy the Sample Application Automatically
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 domain-root-dir, which is as-install/domains
:
as-install/domains/domain1/autodeploy
Before You Begin
The sample application must be available before you start this task. To download the sample, see To Obtain the Sample Application.
Copy the application WAR file to the domain-dir/autodeploy
directory.
On UNIX, Linux, and Mac OS X systems, type this command:
cp
sample-dir
/hello.war as-install/domains/domain-dir/autodeployOn Windows systems, type this command:
copy
sample-dir
\hello.war as-install\domains\domain-dir\autodeploy
GlassFish Server automatically discovers and deploys the application. The default URL for the application is as follows:
http://localhost:8080/hello/
To Undeploy the Sample Application Automatically
Change to the domain's
autodeploy
directory.cd as-install\domains\domain-dir\autodeploy
Delete the sample application's WAR file to undeploy and remove the application.
On UNIX, Linux, and Mac OS X systems, type this command:
rm hello.war
On Windows systems, type this command:
del hello.war
Removing GlassFish Server 4.0 Software
Before removing the GlassFish Server software, stop the following processes:
All domains and other related processes
Command prompts that use the installation directory or its subdirectories
The Update Tool notifier process if present
Any applications that use files that are part of the Java Platform, Standard Edition (Java SE)
For more information about performing these tasks, see Uninstalling GlassFish Server, in Oracle GlassFish Server Installation Guide.
To Remove GlassFish Server Software on UNIX, Linux, and Mac OS X Systems
Change to the as-install-parent directory, which contains the uninstallation program.
If necessary, grant execute permissions to the uninstallation program file.
chmod +x ./uninstall.sh
Run the uninstallation program.
./uninstall.sh
Examine the contents of the remaining installation directories and remove any files or directories that you do not want, including hidden directories prefixed with a dot.
To Remove GlassFish Server Software on Windows Systems
Change to the as-install-parent directory, which contains the uninstallation program.
Run the uninstallation program.
uninstall.exe
Examine the contents of the remaining installation directories and remove any files or directories that you do not want, including hidden directories prefixed with a dot.
For More Information
Additional resources are available to help you learn more about GlassFish Server 4.0 and related technologies.
The following resources are described here:
Product Documentation
Comprehensive product documentation is available and includes the following.
Release Notes: Latest details about new features, known issues, and tips for installing and working with GlassFish Server software.
The GlassFish Product Documentation page: Collection of guides that document GlassFish Server Open Source Edition features and functions.
GlassFish Server Screencasts: Collection of video recordings that demonstrate various features and provide examples for working with GlassFish Server and related technologies.
GlassFish Server FAQs: Frequently asked questions covering a variety of GlassFish Server topics.
GlassFish Communities
The following resources will help you connect with other users, learn more about GlassFish Server, and get help if needed.
GlassFish Forum: Public online discussion forum that provides community support and tips for working with GlassFish Server.
GlassFish Wiki: Community site that provides a wide range of information related to GlassFish Server.
GlassFish Quality Community: Quality community site focused on testing and improving GlassFish Server.
Tutorials
The following tutorials provide working examples and detailed instructions for creating enterprise applications for the Java EE 7 platform.
Your First Cup: An Introduction to the Java EE Platform: Provides a short tutorial for beginning Java EE programmers that shows how to develop a simple enterprise application from scratch. The sample application consists of four main components: a JAX-RS RESTful web service, an enterprise bean, a Java Persistence API entity, and a web application created with JavaServer Faces Facelets technology.
The Java EE 7 Tutorial: Provides a beginner's guide to developing enterprise applications for GlassFish Server. The tutorial includes working examples and instructions for creating applications with Java EE 7 technologies, including Java Servlets, JavaServer Faces, Facelets, RESTful Web Services, Enterprise JavaBeans, Java Persistence API, Contexts and Dependency Injection for the Java EE platform, and more. The document is also available through Update Tool.
Java EE 7 Samples
The sample applications demonstrate Java EE technologies. The samples are available through Update Tool and also as part of the Java EE 7 SDK distributions. The SDK distributions are available from the Java EE SDK downloads page.