4.4.1. Building The Application
Let's look at building the example application and then explore the configuration files in detail.
In Chapter 3, About the Example Applications, we looked at the directory structure of the jsfejb3
sample application. At the command line, go to the jsfejb3
directory. There you will see a build.xml
file. This is our Ant build script for compiling and packaging the archives. To build the application, you need to first of all edit the build.xml
file and edit the value of jboss-dist
to reflect the location where the JBoss Application Server is installed. Once you have done this, just type the command ant
and your output should look like this:
[user@localhost jsfejb3]$ ant Buildfile: build.xml compile: [mkdir] Created dir: /jboss/gettingstarted/jsfejb3/build/classes [javac] Compiling 4 source files to /home/skittoli/Desktop/gettingstarted/jsfejb3/build/classes [javac] Note: /jboss/gettingstarted/jsfejb3/src/TodoDao.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. war: [mkdir] Created dir: /jboss/gettingstarted/jsfejb3/build/jars [war] Building war: /jboss/gettingstarted/jsfejb3/build/jars/app.war ejb3jar: [jar] Building jar: /jboss/gettingstarted/jsfejb3/build/jars/app.jar ear: [ear] Building ear: /jboss/gettingstarted/jsfejb3/build/jars/jsfejb3.ear main: BUILD SUCCESSFUL Total time: 3 seconds
If you get the BUILD SUCCESSFUL message, you will find a newly created build
directory with 2 sub-directories in it:
classes: containing the compiled class files.
jars: containing three archives - app.jar
, app.war
and jsfejb3.ear
.
app.jar : EJB code and descriptors.
app.war : web application which provides the front end to allow users to interact with the business components (the EJBs). The web source (HTML, images etc.) contained in the jsfejb3/view
directory is added unmodified to this archive. The Ant task also adds the WEB-INF
directory that contains the files which aren’t meant to be directly accessed by a web browser but are still part of the web application. These include the deployment descriptors (web.xml
) and extra jars required by the web application.
jsfejb3.ear : The EAR file is the complete application, containing the EJB modules and the web module. It also contains an additional descriptor, application.xml
. It is also possible to deploy EJBs and web application modules individually but the EAR provides a convenient single unit.