Sun GlassFish Enterprise Server Quick Start Guide
Sun GlassFish Enterprise Server v3 Prelude (GlassFish server) provides the following:
A lightweight and extensible core based on OSGi Alliance standards
A web and scripting container
An easy-to-use Administration Console for configuration and management
Update Center connectivity
This document provides the following topics:
How This Quick Start Guide Works
The Sun GlassFish Enterprise Server v3 Prelude Quick Start Guide enables you to quickly learn the basics about key GlassFish server features.
Step-by-step procedures introduce you to product features and allow you to learn about and use them immediately.
The instructions and examples in this document use the forward slash character (/) as path separators in all file and command names. Be sure to use the correct character for the system that GlassFish server is installed on. For example:
UNIX® systems or Linux systems — installation-directory/bin/asadmin
Windows systems or Mac OS X systems — installation-directory \bin\asadmin
This document provides fundamental information only. For links to comprehensive information about GlassFish server or other entities mentioned in this document, see For More Information. When this guide is updated, the most recent version is available in the GlassFish server v3 Prelude documentation collection.
Obtaining GlassFish Server v3 Prelude Software
To read additional details about this release before you begin, review the Sun GlassFish Enterprise Server v3 Prelude Release Notes. The Release Notes provide recent information, limitations, and tips for installing and working with GlassFish server v3 Prelude software.
To use this guide to explore the GlassFish server features, GlassFish server v3 Prelude software must be installed on your system. You have these options:
Install GlassFish server v3 Prelude. If you do not have this software, select one of the following installation options:
Download the demonstration version following the steps in this guide. For instructions, see Installing And Updating GlassFish Server v3 Prelude Software.
Follow the installation instructions provided in Sun GlassFish Enterprise Server v3 Prelude Installation Guide.
Note - The GlassFish server installation requires JDK 5 release or JDK 6 release. Make sure that the JDK 5 release or JDK 6 release bin directory is in your PATH so that the java binary used with GlassFish server comes from the JDK release rather than a JavaTM Runtime Environment implementation.
Use an existing installation of GlassFish server v3 Prelude.
If you already have the latest version of GlassFish server v3 Prelude software, go to Starting and Stopping the Default Domain to start looking at key features of GlassFish server.
Update an existing installation of GlassFish server v3 Prelude.
If you have an older version of the software, update to the latest version. For instructions, see Updating a GlassFish Server Software Installation.
Installing And Updating GlassFish Server v3 Prelude Software
This section provides instructions for installing and updating GlassFish server software.
Tip - If GlassFish server v3 Prelude software is already installed and updated, you can skip this section and go to Starting and Stopping the Default Domain.
Performing a GlassFish Server Installation
This section provides instructions for installing GlassFish server v3 Prelude software.
To Install GlassFish Server Software
- Select a directory to install GlassFish server.
- Use the default directory.
If you do not specify an installation directory, the software will be installed in the following directories:
UNIX systems or Linux systems — user-home-directory /glassfishv3-prelude
Windows systems — C:\Program Files\glassfishv3-prelude
MacOS X systems — /Applications/glassfishv3-prelude
- Set up a directory for installing GlassFish server.
Throughout this document, the directory you choose for installing is referred to as as-install.
- Use the default directory.
- Download the glassfish-v3-prelude.zip
file to the installation directory.
This platform-independent ZIP file can be used on SolarisTM, Linux, MacOS X, and Windows platforms.
- Use the cd command to change to the installation directory.
cd as-install
- Unzip the bundle.
unzip gfv3-prelude.zip
The v3 Prelude distribution is installed into a new glassfishv3-prelude directory under your current installation directory.
- To explore GlassFish server features, go to Starting and Stopping the Default Domain.
Updating a GlassFish Server Software Installation
This section provides instructions for using the GlassFish server v3 Prelude Administration Console to update your installation.
If you have already installed a current version GlassFish server v3 Prelude, skip this section and go to Starting and Stopping the Default Domain.
To Update an
Existing GlassFish Server Installation
Before You Begin
At least one GlassFish server domain must be started before you launch the Administration Console.
- To open the Administration Console, type the URL in a browser window.
The default URL for the Administration Console is:
http://localhost:4848
- Log in to the Administration Console.
- From the navigation tree, select Update Tool.
- From the navigation tree, click the Available Updates tab.
Components with available updates are listed.
If no components are listed, your GlassFish server v3 Prelude installation is current. Go to Starting and Stopping the Default Domain.
- Select the components that you want to update, and click Update.
- Accept license agreements that are presented.
- To verify the update, click the Installed Components tab.
Starting and Stopping the Default Domain
By default, when you install GlassFish server, a default domain named domain1 is created.
To
Start the Default Domain
Before You Begin
GlassFish server software must be installed before you start the domain.
- To start the default domain, use the start-domain command.
- Use the short form:
as-install/bin/asadmin start-domain
- Use the long form:
java -jar as-install /modules/admin-cli-10.0-SNAPSHOT.jar start-domain
Either command starts the default domain, domain1.
- Use the short form:
To
Stop the Default Domain
- To stop the default domain, use the asadmin stop-domain command.
- Use the short form:
as-install/bin/asadmin stop-domain
- Use the long form:
java -jar as-install /modules/admin-cli-10.0-SNAPSHOT.jar stop-domain
Either command stops the default domain, domain1.
- Use the short form:
Starting and Stopping the Database Server
A database server is not started by default when you start the GlassFish server domain. If you have applications that need a database back end, you must start and stop the database server manually.
To Start the Sun GlassFish Java DB Server
The instructions in this procedure describe how to start the Java DB server that is bundled with GlassFish server, but they apply for the most part to any database you want to use.
Before You Begin
At least one GlassFish server domain must be started before you start the database server.
- Use the asadmin start-database command.
The general form for the command is:
as-install/bin/asadmin start-database --dbhome directory-path
For example, to start the Sun GlassFish from its default location:
as-install/bin/asadmin start-database --dbhome as-install/javadb
To
Stop the Java DB Server
- Use 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 the GlassFish server and your domains.
To Launch the
Administration Console
Before You Begin
At least one GlassFish server domain must be started before you launch the Administration Console.
- To open the Administration Console, type the URL in a browser window.
The default URL for the Administration Console is:
http://localhost:4848
- Log in to the Administration Console.
By default, the user name is anonymous and the Password field is left blank (no password).
See Also
Refer to the Administration Console online help for further instructions.
Deploying and Undeploying Applications
The process of configuring and enabling an application to run within the GlassFish server framework is referred to as deployment.
Note - In the v3 Prelude release, applications can be packaged for deployment in web archive (WAR) format only.
This section explains how to deploy, list, and undeploy applications.
Obtaining a Sample Application
The procedures in this section use the hello.war application.
To Obtain a
Sample Application
- To download a copy of the hello.war sample, go to https://glassfish.dev.java.net/downloads/quickstart/hello.war .
- Click Yes to save the hello.war file.
- Save the hello.war file in the directory of your choice. This document refers to this directory as sample-dir.
Deploying an Application from the Command Line
You can deploy applications from the command line by using the asadmin deploy command.
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 Obtaining a Sample Application. At least one GlassFish server domain must be started before you deploy the sample application.
- Use the asadmin deploy command.
The general form for the command is:
as-install/bin/asadmin deploy war-name
To deploy the hello.war sample, the command is:
as-install/bin/asadmin deploy sample-dir/hello.war
- Access the hello application by typing the following URL in
a browser window:
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
See deploy(1) for more information about the deploy command.
See Sun GlassFish Enterprise Server v3 Prelude Application Deployment Guide for more information about deploying applications from the command line.
To List Deployed Applications From the
Command Line
- Use the asadmin list-applications command:
as-install/bin/asadmin list-applications
To
Undeploy the Sample Application From the Command Line
- Use the asadmin undeploy command.
The general form for the command is:
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-install/bin/asadmin undeploy hello
See Also
See undeploy(1) for more information about the undeploy command.
Deploying an Application by Using the Administration Console
You can deploy applications from the graphical Administration Console.
To Deploy the
Sample Application From the Administration Console
Before You Begin
The sample application must be available before you start this task. To download the sample, see Obtaining a Sample Application. At least one GlassFish server domain must be started before you deploy the sample application.
- Open the Administration Console by typing the following URL in a browser
window:
http://localhost:4848
- Click the Applications node in the tree on the left.
The node expands to display the Web Applications subnode.
- Click the Web Applications subnode.
The Web Applications page is displayed.
- Click Deploy.
The Deploy Enterprise Applications/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,
and then click Open.
You are returned to the Deploy Enterprise Applications/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 Web Applications page.
- Run the sample application.
- Click the Launch link on the Web Applications page.
- Type the following URL in a browser window:
http://localhost:8080/hello/
See Also
Refer to the Administration Console online help for further instructions.
To View Deployed Applications in the
Administration Console
- Open the Administration Console by typing the following URL in a browser
window:
http://localhost:4848
- Click the Applications node in the tree on the left.
The node expands to display the Web Applications subnode.
- Click the Web Applications subnode.
The list of deployed web applications is displayed in the Deployed Web Applications table on the Web Applications page.
To
Undeploy the Sample Application From the Administration Console
- Open the Administration Console by typing the following URL in a browser
window:
http://localhost:4848
- Click the Applications node in the tree on the left.
The node expands to display the Web Applications subnode.
- Click the Web Applications subnode.
The Web Applications page is displayed.
- Select the check box next to the applications you want to undeploy.
- Remove or disable the application.
- To remove the application, click Undeploy.
- To disable the application, click Disable.
Deploying an Application Automatically
To use automatic deployment, you can deploy applications by placing the applications in the as-install/domains/domain-name/autodeploy directory.
To Deploy the Sample Application Automatically
Before You Begin
The sample application must be available before you start this task. To download the sample, see Obtaining a Sample Application .
- Create a directory named as-install/domains/domain-name
/autodeploy
domain-name is the name of the domain for which you want to configure automatic deployment. For this example, use the default domain1 domain:
as-install/domains/domain1/autodeploy
- Copy the application WAR file to the as-install/domains/
domain-name/autodeploy directory.
cp sample-dir/hello.war as-install/domains/domain-name /autodeploy
GlassFish server automatically discovers and starts the application.
To
Undeploy the Sample Application
- Use the cd command to change to the domain's autodeploy directory.
cd as-install/domains/domain-name /autodeploy
- Use the rm command to delete the application.
rm hello.war
Removing GlassFish Server v3 Prelude Software
Uninstall the GlassFish server software after you have completed using this guide, if you no longer want to use the software.
To Remove GlassFish Server Software
Before You Begin
Stop all GlassFish server processes that are running.
- Change to the directory where GlassFish server v3 Prelude is installed.
The default installation directory is user's-home-directory/glassfish-v3prelude .
- Run the uninstallation command.
- (Solaris or Linux or MacOS X) From the command line, type the following
command:
./unistall.sh
- (Windows) Double-click the gfv3-v3-prelude-uninstall.exe file.
- (Solaris or Linux or MacOS X) From the command line, type the following
command:
- Examine the contents of your directories to verify that the GlassFish server v3 Prelude software is removed.
For More Information
This section provides links to commonly used resources in the following areas:
Many other add-on components for GlassFish server v3 Prelude are available through Update Tool.
Communities
GlassFish Wiki — Open source development community site that provides a wide range of topics related to the GlassFish project.
GlassFish Documentation — Open source documentation community site that provides details about the GlassFish documentation project.
Development Tools
NetBeans 6.5 — An integrated development environment and application platform for web, enterprise, desktop, and mobile applications. Download NetBeans TM IDE 6.5 with GlassFishTM Application Server and MySQLTM Community Server from NetBeans IDE 6.1 Download page.
Eclipse — A development environment that provides a framework, tools, and runtime for deploying and managing software.
Scripting
JRuby and Rails— A scripting language and a framework for developing web applications.
Grizzly— A framework for building scalable and robust servers using New I/O (NIO) APIs. The ability to embed components that support HTTP, Bayeux Protocol, Servlet and Comet is provided.
Getting Started With Project jMaki for Sun GlassFish Enterprise Server v3 Prelude— A framework for creating Ajax web applications.
Product Documentation
Sun GlassFish Enterprise Server v3 Prelude Release Notes — Recent information, limitations, and tips for installing and working with GlassFish server.
GlassFish server documentation — Collection of guides that document GlassFish server features and functions.
GlassFish server Screencasts — Collection of video recordings that demonstrate numerous features and examples for working with GlassFish server and related projects.
GlassFish server FAQs — Frequently asked questions covering various GlassFish server topics.
Tutorials
Java EE 5 Tutorial — Instructions, examples, and sample code for working with all Java platform core technologies.
User Forum
Glass Fish community — Public online discussions that provide community support and tips for working with GlassFish server.