JavaServer Faces: The Complete Reference

How to set up your own ANT JSF build environment

This How-To provides guidance on how to set up your own ANT based environment in order to compile and run the code samples from the book.

Step 1. Download the required jar files

For JSF 1.0/1.1 a set of jar files must be added to your Web application in order for it to run Faces applications. This contrasts with JSF 1.2 where the container has all of the necessary jar/classes for running JSF.

The provided ANT sample build.xml and its associated build.properties file have references to the required jar files for JSF. These are:

# Jars for JCP Standards

servlet.jar= Local path to servlet-api.jar
jsp.jar=Local path to jsp-api.jar
jstl.jar=Local path to jstl.jar
jsf-api.jar=Local path to jsf-api.jar

# Jars for implementations of JCP standards

standard.jar=Local path to standard.jar
jsf-impl.jar=Local path to jsf-impl.jar

# Jars for miscellaneous dependencies required by Sun's JSF 1.1
# implementation

commons-beanutils.jar=Local path to commons-beanutils.jar
commons-collections.jar=Local path to commons-collections.jar
commons-digester.jar=Local path to commons-digester.jar
commons-logging.jar=Local path to commons-logging.jar

Obtaining the necessary jar files is easily done by downloading from three general areas:

1. J2EE Container such as Tomcat

Tomcat will contain the both servlet-api.jar and jsp-api.jar in its common/lib directory.

http://tomcat.apache.org/download-55.cgi (Download link for Tomcat 5.x)

2. JSF API and implementation jar files: jsf-api.jar, jsf-impl.jar

From Sun:

http://java.sun.com/javaee/javaserverfaces/download.html

(Alternatively) From MyFaces:

http://myfaces.apache.org/download.html

3. Jakarta Commons libraries: commons-beanutils.jar, commons-collections.jar, commons-digester.jar, commons-logging.jar.

These are bundled in the reference implementations, but can also be downloaded separately:

http://jakarta.apache.org/commons/

4. Jakarta Standard 1.1 Taglib: jstl.jar, standard.jar.

http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi

 

Step 2. Edit your properties file with the jar locations

Once downloaded, you can then reference in your properties file. Here is an example build.properties file with references to the jar files.

# Jars for JCP Standards

servlet.jar=C:/Program Files/Apache/Tomcat 5.5.7/common/lib/servlet-api.jar
jsp.jar=C:/Program Files/Apache/Tomcat 5.5.7/common/lib/jsp-api.jar
jstl.jar=C:/jakarta-libs/jstl.jar
jsf-api.jar=C:/jsf/jsf-1_1_01/lib/jsf-api.jar

# Jars for implementations of JCP standards

standard.jar=C:/jakarta-libs/standard.jar
jsf-impl.jar=C:/jsf/jsf-1_1_01/lib/jsf-impl.jar

# Jars for miscellaneous dependencies required by Sun's JSF 1.1
# implementation

commons-beanutils.jar=C:/jakarta-libs/commons-beanutils.jar
commons-collections.jar=C:/jakarta-libs/commons-collections.jar
commons-digester.jar=C:/jakarta-libs/commons-digester.jar
commons-logging.jar=C:/jakarta-libs/commons-logging.jar

Step 3. Install ANT if you haven't done so already!

The book used ANT version 1.6.5.

http://ant.apache.org/

Step 4. Run "ant" to build the WAR files for each chapter.

In the directory where the build.xml files are located for each chapter's examples, type "ant" at the command line to create the deployable WAR files in a /build subdirectory. The generated WAR file can then be deployed to any standard J2EE container (Tomcat, OC4J, Weblogic, Sun Appsvr, and so on)

To clean out the generated /build subdirectory run "ant clean".

 

Finally, its important to remember that if you use a JSF enabled IDE such as the ones listed in Chapter 17, you don't have to manually download each set of Jar files!

Return to download page


Contact Information | For general questions: jsfcomprefinfo | For errata: jsfcompreferrata