GlassFish Full Build Instructions
These instructions are for those who want to fully build everything from scratch. Most developers should follow DevelopmentInstructions. To build GlassFish V2, see here .
Maven version
You can use Maven 3.0.3. If you are using Maven 2, you must use version 2.2.1, as previous versions of MAVEN have led to issues building v3. If you see a compilation error relating to ".../PwcCoyoteRequest.java:146: cannot find symbol" then most likely you are using a pre-2.0.9 versions of Maven. There is known issue in Maven where HashSet is used to store classpath thus resulting in unpredictable ordering of classpath during compilation.
Do not use Maven 2.2.0 as there are critical regressions in this version and you will not be able to compile GFv3.
If you don't have Maven installed, download it here.
JDK version
You must use JDK 1.6 Update Release 4 or above to build GlassFish v3 and make sure that it's in the PATH. Please note, we need update release 4 of JDK 1.6 because Metro depends on some new JAX-WS APIs.
Checkout the workspace
To checkout the entire trunk workspace,
If you don't have svn, please download it here.
To checkout the 3.1.2 workspace,
To checkout the 3.1.1 workspace,
To checkout the 3.1 workspace,
To checkout the 3.0.1 FCS workspace,
To checkout the 3.0 FCS workspace,
To checkout the V3Preview workspace,
To checkout the V3Prelude workspace,
Tip: If you don't have svn installed, you can use mvn to checkout trunk workspace:
This command will create a subdirectory 'main' from the directory where you run the command. You can do the same for V3Prelude workspace by replacing the URL.
After that, perform the following steps to build GFv3
Note: if you get a java OutOfMemory Error while running the mvn command, add this entry to your shell's rc file or environment:
Tip: If you want to dedicate a maven local repository:
Re-build from existing workspace,
You can use the "-U" option if you want maven to check and download the updated SNAPSHOT and release artifacts. However, build will take much longer using this option. If you have one successful build which means your local Maven repository (by default it's <user-home>/.m2/repository) is populated with the artifacts referenced in GlassFish v3 workspace, then you don't need to use "-U".
You can use the "clean" target if you want maven to delete the modules' target directories and force maven to build all the modules. Without the clean target, maven will build the modules that have been modified.
NOTE if your code change impacts other modules, it is recommended that you do a "clean".
Also, once you have a successful build, you can build selected modules in the v3 directory by using the "-pl or --projects" option.
e.g.
If you already have a GlassFish installation and would like to update that jar files built in your workspace to the installed glassfish/modules directory, you can either directly copy to the glassfish/modules directory or create a symlink in Unix/Linux or use Junction in Windows OS (see here.
Currently the Maven GlassFish Build plugin's "run" goal (described here) is broken due to changes in the GlassFish launcher code. Once this is fixed, you can also use this option to start domain with the artifacts built in your workspace.
Distributions
At the end of this, you will have various distributions. These distributions are nothing but zip files with specific Main Class and contents. For example, one of the distributions is the GlassFish distribution available at: main/appserver/distributions/glassfish/target, named glassfish.zip.
Note that the so-called "admin domain" is already available as a zipped-up folder with prebuilt structure. This is a deviation from how GlassFish V2 used to install/create the domain.
Running V3
Unzip the distribution in your favorite directory and do
where the option --verbose|-v starts the server embedded, in the same vm and displays the server log on the console
or
you can then use the asadmin client to deploy applications
Note: Make sure that you are using JDK 1.6 update release 4 or above and it must be in the path.
Building Offline
You can build offline if you have all the external dependencies downloaded in the local Maven repository. The dependencies are downloaded if you have a previously successful v3 build. To build offline, use the following command:
Kenai Migration
If you have an existing workspace from java.net (Collab) and would like to switch to the new java.net (Kenai) infrastructure, please use switch --relocate command.
Building Embedded
You must first build main workspace and have a local Maven repository containing the main/appserver and main/nucleus artifacts. The embedded workspace will need to reference the same local Maven repository used for building main. If you're not using the default Maven repository, (<home>/.m2/repository), you can set the local Maven repository with the property -Dmaven.repo.local=... on the command line. If you just want to build embedded without building v3, the v3 SNAPSHOT artifacts from the remote Maven repository will be used to assemble the embedded artifacts.
Embedded All
cd main/appserver/extras/embedded/all
mvn install
Embedded Nucleus
cd main/appserver/extras/embedded/nucleus
mvn install
Embedded Web
cd main/appserver/extras/embedded/web
mvn install
Decision Regarding Binary Class Version of GlassFish Build.
This was discussed during the engineering meeting on Tuesday 17 Feb 2009.
Since by definition, Java EE 6 requires Java SE 6 runtime, it is obvious that we use Java 6 for compilation. Thus, the javac used for compilation of Java sources in GlassFish v3 trunk is <java6>/bin/javac (or its equivalent). Now, the target for such a build is Java 6 runtime. Thus, by default, i.e. if we don't specify the -target option on javac, the generated classes would have a Major Version of 50.0 (which corresponds to Java 6). Thus, if we did that, all the modules will only create classes that can be loaded by Java 6 runtime. In order to support Java 5 runtime (ListOfV3ModulesSupportingJava5Runtime) which might be required by some of the components (although their source are checked in to v3 trunk), here is the decision taken:
- GlassFish v3 must be run with Java 6+ runtime only. (Can someone clarify if it applies to all the distro's?)
- We use javac from Java 6 for compilation. Because of that, any module can declare compile-time dependencies on Java 6 classes, e.g. java.io.Console.
- We use -target as 1.5 which means, by default, the major version of classes generated by build would be 49. This is to take care of running certain modules with Java 5 runtime.
- asadmin will detect an attempt to run GlassFish with Java 5 Runtime See: 7038 and will flag it as an error.
3 Comments
comments.show.hideAug 02, 2011
stadelma
Why do we have to checkout from ./branch/... but not from ./tags/... ?
Today someone renamed ./branches/3.1.1 to ./branches/3.1.2
This page: http://wikis.sun.com/display/GlassFish/FullBuildInstructions
explains to new-comers like me how to fully build from sources.
And beleve me it would work for me much better if I can expect sources
to come from a stabe place as normaly found under ./tags then a branch
which seems to change or gets renemd on the fly.
Josef
Aug 08, 2011
pareto99
Thank for the exhaustive instructions... I am also new to this and I will probably have to bookamrk this page and refer to it a few times but I do get the gist of it.
Thanks!
Pareto@
Business Ideas
Nov 02, 2011
veit_ullmann
I want to import the glassfish projects into eclipse for debugging, which prject do I have to import?