Sun GlassFish Enterprise Server 2.1 Developer's Guide

Chapter 1 Setting Up a Development Environment

This chapter gives guidelines for setting up an application development environment in the Sun JavaTM System Enterprise Server. Setting up an environment for creating, assembling, deploying, and debugging your code involves installing the mainstream version of the Enterprise Server and making use of development tools. In addition, sample applications are available. These topics are covered in the following sections:

Installing and Preparing the Server for Development

For the Sun Java Enterprise System, Enterprise Server installation is part of the system installation process. For more information, see

For more information about stand-alone Enterprise Server installation, see the Sun GlassFish Enterprise Server 2.1 Installation Guide.

The following components are included in the full installation.

The NetBeansTM Integrated Development Environment (IDE) bundles the GlassFish edition of the Enterprise Server, so information about this IDE is provided as well.

After you have installed Enterprise Server, you can further optimize the server for development in these ways:

The GlassFish Project

Enterprise Server is developed through the GlassFishTM project open-source community at The GlassFish project provides a structured process for developing the Enterprise Server platform that makes the new features of Java EE 5 available faster, while maintaining the most important feature of Java EE: compatibility. It enables Java developers to access the Enterprise Server source code and to contribute to the development of the Enterprise Server. The GlassFish project is designed to encourage communication between Sun engineers and the community.

The Java ES edition of the Enterprise Server is based on the GlassFish source code, but provides additional value-added features such as access to a high-availability database (HADB) for session persistence and failover.

Usage Profiles

When you install a domain, the usage profile you select determines the features that are available by default. Here is a summary of the usage profiles:

For more information about usage profiles, see Usage Profiles in Sun GlassFish Enterprise Server 2.1 Administration Guide.

High Availability Features

High availability features such as load balancing and session failover are discussed in detail in the Sun GlassFish Enterprise Server 2.1 High Availability Administration Guide. This book describes the following features in the following sections:

Development Tools

The following general tools are provided with the Enterprise Server:

The following development tools are provided with the Enterprise Server or downloadable from Sun:

The following third-party tools might also be useful:

The asadmin Command

The asadmin command allows you to configure a local or remote server and perform both administrative and development tasks at the command line. For general information about asadmin, see the Sun GlassFish Enterprise Server 2.1 Reference Manual.

The asadmin command is located in the as-install/bin directory. Type asadmin help for a list of subcommands.

The Admin Console

The Admin Console lets you configure the server and perform both administrative and development tasks using a web browser. For general information about the Admin Console, click the Help button in the Admin Console. This displays the Enterprise Server online help.

To access the Admin Console, type http://host:4848 (developer profile) or https://host:4848 (cluster and enterprise profiles) in your browser. The host is the name of the machine on which the Enterprise Server is running. By default, the host is localhost. For example:


The asant Utility

Apache Ant 1.6.5 is provided with the Enterprise Server and can be launched from the bin directory using the command asant. The Enterprise Server also provides server-specific tasks for administration and deployment; see Chapter 3, The asant Utility. The sample applications that can be used with the Enterprise Server use Ant build.xml files; see Sample Applications.

For more information about Ant, see the Apache Software Foundation web site at

The verifier Tool

The verifier tool checks a Java EE application file, including Java classes and deployment descriptors, for compliance with Java EE specifications. Java EE application files are Java archive (JAR), web archive (WAR), resource adapter archive (RAR), or enterprise archive (EAR) files. Use the verifier tool to check whether an application complies with the Java EE specification and to make applications portable across application servers. The verifier tool can be launched from the command line. For more information, see The verifier Utility in Sun GlassFish Enterprise Server 2.1 Application Deployment Guide.

The NetBeans IDE

The NetBeans IDE allows you to create, assemble, and debug code from a single, easy-to-use interface. The GlassFish edition of the Enterprise Server is bundled with the NetBeans 5.5 IDE. To download the NetBeans IDE, see This site also provides documentation on how to use the NetBeans IDE with the bundled Enterprise Server.

You can also use the Enterprise Server with the Sun Java Studio 8 software, which is built on the NetBeans IDE. For more information, see

The Migration Tool

The Migration Tool converts and reassembles Java EE applications and modules developed on other application servers. This tool also generates a report listing how many files are successfully and unsuccessfully migrated, with reasons for migration failure. For more information and to download the Migration Tool, see

Debugging Tools

You can use several debugging tools with the Enterprise Server. For more information, see Chapter 4, Debugging Applications.

Profiling Tools

You can use several profilers with the Enterprise Server. For more information, see Profiling Tools.

The Eclipse IDE

A plug-in for the Eclipse IDE is available at This site also provides documentation on how to register the Enterprise Server and use Sun-specific deployment descriptors.

Sample Applications

Sample applications that you can examine and deploy to the Enterprise Server are available. If you installed the Enterprise Server as part of installing the Java EE 5 SDK bundle from Java EE 5 Downloads, the samples may already be installed. You can download these samples separately from the Code Samples page if you installed the Enterprise Server without them initially.

Most Enterprise Server samples have the following directory structure:

With a few exceptions, sample applications follow the standard directory structure described here:

The samples-install-dir/bp-project/main.xml file defines properties common to all sample applications and implements targets needed to compile, assemble, deploy, and undeploy sample applications. In most sample applications, the build.xml file imports main.xml.

In addition to the Java EE 5 sample applications, samples are also available on the GlassFish web site at