Dinesh Patil's Weblog

Dinesh Patil's Weblog

All | Personal | Sun

20060217 Friday February 17, 2006

 GlassFish Build

GlassFish  Build made Easy GlassFish


Introduction:

Welcome to the wonderful world of GlassFish! GlassFish is the name for the open source development project for bulding a Java EE 5 application server. It is based on the source code for Sun Java System Application Server PE 9 donated by Sun Microsystems and TopLink persistence code donated by Oracle. It is the response to Java developers who want access to the source code and the ability to contribute to the development of Sun's next generation application server which is based on GlassFish. This project is designed to encourage communication between Sun and Oracle engineers and the community and will enable all developers to participate in the application server development process.

This document will focus on the glassfish project workspace and will show you how to:

  • Check out the latest GlassFish development sources from CVS
  • Setup your build environment
  • Build GlassFish
  • Start and verify the Server
  • Execute the Quicklook tests

To follow the GlassFish workspace, simply read the sections in order and perform the tasks which each section defines.

Requirements:

First of all, you need to sign up to get java.net User ID from GlassFish developers community https://glassfish.dev.java.net. Glassfish workspace is built using Apache Maven 1.0.2. All GlassFish modules use Maven as a build tool, which replaces gmake. Maven is available on all platform supporting Java.

Build tools requirement to start working with GlassFish workspace:
    • Apache Maven 1.0.2  as a build framework replacing gmake/shell scripts
    • JDK 1.5.0_06 or later, and define JAVA_HOME, and add into executable PATH variable.
    • Setup CVS Client for checking out sources from java.net CVS Repository, so users need to login the repository.
Following OS specific requirements:
    • A UNIX (posix) or Windows (win32) compatible operating system.
    • Sun Solaris 9, 10 (SPARC) Solaris 9, 10 (x86) Memory: 512 MB, Disk Space: 250 MB free
    • 64–bit Sun Solaris 10 (SPARC, x86) : Memory 512 MB, Disk Space: 250 MB free
    • Redhat Enterprise Linux 3.0 U1, 4.0 : Memory 512 MB, Disk Space- 250 MB free 
    • Windows Server 2000 SP4+, Windows 2000 Advanced Server SP4+, Windows Server 2003, Windows XP Pro SP1+ : Memory 1 GB, Disk Space 500 MB free
    • MAC OS X (not for standalone Platform Edition; via Tools only) : Memory 512 MB, Disk Space 250 MB free 
Build Flexibility
  • It is possible to check out and build each independent module separately. Also it is be possible for a module engineer (e.g. appserv-webtier) to just check out the relevant module files instead of the checking out the entire workspace.
  • It is possible to build the entire source tree from a top level directory / workspace from glassfish/bootstrap.
  • It doesn't require developer to download and setup any tools other than Maven, JDK, and CVS client.
  • Maven is new, evolving build tool so can utilize the new developements in maven by applying the same to GlassFish workspace.
  • There is a facility for obtaining a "binary" module (i.e. one whose source code is not available) from the remote repository. Its flexible to add any third party dependencies by staging the binary into the Remote repository and edit configuration files, and developer is free to download and use any number of binary modules on the project.
  • Developers don't have to compile and build every dependent module. Instead it is possible to retrieve a pre-compiled and tested version of the module. They are also be able to download an entire Glassfish installation (called Glassfish image) and build the module against it using "maven bootstrap" build type.
  • The build environment must be completely reproducible meaning that all tools and external modules used in the build environment can be retrieved from a known location.
  • Workspace doesn't depend on any shared server or remote network directory.
Checkout the Sources:

You can get the sources for the glassfish project from CVS. To get the sources from CVS, follow the instructions on the CVS page to get and setup your CVS client. Once you have done that you can check out the module:

% cvs -d :pserver:dpatil@cvs.dev.java.net:/cvs checkout glassfish/bootstrap

You should see output similar to:

U glassfish/bootstrap/ant-common.xml
U glassfish/bootstrap/appserv-admin.mf
U glassfish/bootstrap/appserv-cmp.mf
U glassfish/bootstrap/appserv-deployment-client.mf
U glassfish/bootstrap/appserv-ext.mf
U glassfish/bootstrap/appserv-rt.mf
U glassfish/bootstrap/build.xml
U glassfish/bootstrap/glassfish.subcomponent.properties
U glassfish/bootstrap/glassfish.xml
U glassfish/bootstrap/j2ee-jar.mf
U glassfish/bootstrap/javaee-jar.mf
U glassfish/bootstrap/maven.xml
. . .
U glassfish/bootstrap/legal/3RD-PARTY-LICENSE.txt
U glassfish/bootstrap/legal/BinariesLicense
U glassfish/bootstrap/legal/CDDLv1.0.txt
U glassfish/bootstrap/legal/COPYRIGHT
U glassfish/bootstrap/legal/LICENSE.txt
U glassfish/bootstrap/legal/README
. . .

To get the source for the AS9_BETA_BRANCH Branches use one of the following commands:
% cvs -d :pserver:dpatil@cvs.dev.java.net:/cvs checkout -r AS9_BETA_BRANCH glassfish/bootstrap

Create  glassfish/bootstrap/build.properties or for re-usable GlassFish workspace, one-time process is to create ${HOME}/build.properties (Unix)  or %HOMEPATH%\build.properties (Windows) and  set following variables:
glassfish.os.name= // The OS name - possible values are WINNT, SunOS, Linux, SunOS_X86, Darwin
glassfish.cvs.username= // The java.net id that will be used to checkout the source code.

Once you have checked out glassfish/bootstrap module, do following step to checkout all modules.

% cd glassfish/bootstrap
% maven checkout

Now you will have glassfish directory with a sub-directory layout similar* to this:

activation            appserv-http-engine   CVS                   mail
admin                 appserv-jstl          deployment-api        management-api
admin-cli             appserv-native        ejb-api               persistence-api
admin-core            appserv-webtier       entity-persistence    pwc-commons
admin-gui             avk                   jacc-api              servlet-api
annotation-framework  bootstrap             jacc-provider         tools
appserv-addons        cmp                   jdbcra                transaction-api
appserv-commons       common-util           jms-api               webtier-extensions
appserv-core          connector-api         jmx-remote
appserv-docs          container-auth        jts

* The exact directory layout will change as modules are added or removed from the project. As long as there were no problems durring the checkout everything should be fine.

Understand Your Build Environment

Now that you have the sources you might want to browse through the workspace to become more comfortable with the module and directory structure. The sub-directories inside of glassfish/ are each module directories (except for the CVS/ directory, which we will ignore from now on).  Each module contains the same basic layout with a few exceptions, which you are about to learn.

The bootstrap module is a special module which contains top level build scripts, property files to specify binary libraries and other files which are required for the the build system to function. Unless you are adding new functionality to the build system or updating a binary dependency, you can safely ignore it. This module controls the building of all other modules and is responsible for generating project release directory called ${glassfish.home} and SNAPSHOT files like glassfish-image-SNAPSHOT.jar for installable application server image..

All of the other modules follow a standard layout and usually contain source files in the src/java sub-directory.
Each module has a maven.xml, project.xml, project.properties and build.xml files.
build.xml : the build control file and contains all of the information, targets and tasks to build the module.
other maven build files which are wrappers to build.xml and used for building from top level build module bootstrap using maven tool.

The build system is based on Maven which calls Ant scripts in each module. To build complete GlassFish workspace  you will have to start build from glassfish/bootstrap module.

Once you are comfortable we can start building. As a mandatory configuration step, you need to  pre-initialize the build system and define or set some user local properties like your java.net userid as glassfish.cvs.user and glassfish.os.name. These two variables can be defined in a glassfish/bootstrap/build.properties file or user's home directory ~/build.properties. This file allows you to change how the build system works with on different platform. If this is the first time you are building the sources you might want to look at detailed Glassfish Build Instructions if you run into problems.

GlassFish can be build with NetBeans or using the command line options.  The article has more information on building and developing the GlassFish project with NetBeans.  Command line options for building GlassFish are below.

Build GlassFish
You need to define 2 properties to build the workspace in ${HOME}/build.properties to do Initial Configuration.
glassfish.os.name= The OS name, values can be WINNT, SunOS, SunOS_X86, Linux, Darwin
glassfish.cvs.username=<java.net -id>

Use following command to login to java.net CVS at least once so build checks out sources from java.net repository.
% cvs -d :pserver:<java.net-id>@cvs.dev.java.net:/cvs login

Building entire GlassFish workspace:


% mkdir workspace
% cd workspace
% cvs -d :pserver:<java.net-id>@cvs.dev.java.net:/cvs co glassfish/bootstrap
% cd glassfish/bootstrap
% maven bootstrap-all checkout build

This may take minutes or hours depending on how fast (or slow) your computer is. On an Sun LX50 x86 running solaris 9 it takes about 20 minutes.  The output of the build look something like this:

You may see some warnings durring the build, probably due to the usage of deprecated methods or something, but you can safely ignore those. If everything built with no errors you should see a BUILD SUCCESSFUL message at the end (as shown above).

Checking out a subset of the workspace and build it:
The following steps will checkout a subset of the source, build it. Command: maven bootstrap will download already build glassfish server image (i.e.unzip glassfish-image-SNAPSHOT.jar) and update the server with your new changes.
% mkdir workspace
% cd workspace
% cvs -d :pserver:<java.net-id>@cvs.dev.java.net:/cvs co glassfish/bootstrap
% cd glassfish/bootstrap
% maven checkout -Dmodules=appserv-webtier,webtier-extensions bootstrap build

so your workspace will look like this after the complete build.
cd /workspace
        |--- glassfish_dependencies  (downloaded binaries)
        |--- glassfish (module sources)
        |--- publish/glassfish (server image)

Following 2 variables are defined by default referencing from ${glassfish.root} which is root directory e.g. /workspace as above.
glassfish.home=${glassfish.root}/publish/glassfish
maven.repo.local=${glassfish.root}/glassfish_dependencies

Start GlassFish Server

To Configure the GlassFish Server runtime: following step will create the asadmin script (CLI utility to administer application server), run create-domain, etc which are needed to run the GlassFish server.
    % cd glassfish/bootstrap
    % maven configure-runtime (Default is silent installation)
All GlassFish server commands are located in the ${glassfish.home}/bin directory.  For more documentation on how to administer the application server domain and instances please refer to the documentation for the Sun Java System Application Server PE. 
To Start the Application Server, follow the steps below:
  • Add the install-dir/bin/ (in this case its ${glassfish.home}/bin) directory to the PATH environment variable.
  • Start the server by entering this command: asadmin start-domain domain1.
When the server has started, this message appears:
Domain domain1 is ready to receive client requests. Additional services are being started in the background.

To verify GlassFish server is running on your system, click this URL: http://localhost:8080.
Refer to GlassFish Quickstart Guide for deploying and running a sample application.

Run the Quicklook Tests

Quicklook tests are breadth tests with high-level coverage of many functions in the Application Server. They are meant to give the developer a way of testing major functionality in the Application Server and of running a sanity check to ensure that nothing major is broken.

To run the Quicklook tests:

  1. Install GlassFish or get the server image (${glassfish.home}) bootstrapped using maven bootstrap
  2. Checkout the Quicklook tests
  3. cd workspace (directory where you have the server code)
    cvs -d :pserver:<userid>@cvs.dev.java.net:/cvs checkout glassfish/appserv-tests
  4. Environment settings and permissions:
    • Set the proper environment variables in your .cshrc, or .bat file:
    • Set APS_HOME. This is the directory where you checked out the workspace including the workspace root name (e.g. /workspace/appserv-tests)
    • Set S1AS_HOME. This is installation directory for the Application Server (e.g. /Sun/Appserver)
    • Set JAVA_HOME. This is directory where you installed JDK 5 (e.g. /Sun/jdk1.5.0_01)
    • Set MAVEN_HOME. This is installation directory for Maven 1.0.2 (e.g. /workspace/maven-1.0.2).

    On Unix:  setenv PATH $S1AS_HOME/bin;$JAVA_HOME/bin;$MAVEN_HOME/bin;$PATH
    On Windows: set PATH=%S1AS_HOME%/bin;%JAVA_HOME%/bin;%MAVEN_HOME%/bin;%PATH%

  5. Modify the installation properties under ${APS_HOME}/config.properties to match your installation (e.g. admin.password, http.port, etc.)
  6. Run the test:
    % cd $APS_HOME
    % maven runtest
  7. Open the ${APS_HOME}/test_results.html file in a browser and examine the results, total test count is 50.
What's Next:

Great! You should be proud of yourself for getting this far. As for what you will do next, only you really know that. We suggest reading over the Glassfish Build System Guide, the GlassFish FAQ to get the full view of the build system.

If you are looking for other non-build system developer docs, you can probably find them in the guides section.

Be sure to check out the Project Info for GlassFish on java.net as well as the Contributors Guide.

If you have any ideas, suggestions to enhance on any of the above build steps like some of the ideas listed on GlassFish Enhancement document, just drop an email to dev@glassfish.dev.java.net.

Good luck, happy coding and remember we love you!



Posted by dpatil ( Feb 20 2006, 02:22:43 PM PST / Feb 17 2006, 05:00:00 PM PST ) Permalink Comments [0]
Trackback: http://blogs.sun.com/dpatil/entry/glassfish_build


February 2006 »
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
18
19
20
21
22
23
24
25
26
27
    
       
Today


XML






Today's Page Hits: 25