Professional Documents
Culture Documents
Contents
1 Prerequisite ................................................................................................................................................ 2
Java JDK version 5 or Higher .................................................................................................................. 2
Java EE 6 Speciation .................................................................................................................................. 2
Source Code .............................................................................................................................................. 2
2 Eclipse ........................................................................................................................................................ 3
Download .................................................................................................................................................. 3
Extract ....................................................................................................................................................... 4
3 Tomcat ....................................................................................................................................................... 5
Download .................................................................................................................................................. 5
Extract ....................................................................................................................................................... 6
Configure................................................................................................................................................... 7
Validate ..................................................................................................................................................... 8
4 Maven ..................................................................................................................................................... 10
Download ................................................................................................................................................ 10
Extract ..................................................................................................................................................... 11
M2Eclipse Maven Plug-in for Eclipse ...................................................................................................... 11
5 Building the Web Application using Maven Project ................................................................................ 13
6 Deploying the Web Application using Tomcat Manager App .................................................................. 15
7 Workspace Set up with Eclipse and Tomcat ............................................................................................ 16
7 JSF Code import from WAR File ............................................................................................................... 18
8 Set up workspace from Maven Project .................................................................................................... 21
1 Prerequisite
Java JDK version 5 or Higher
Java EE 6 Speciation
Examples have been built on Java EE Specification i.e.: Servlet Specification 3.0 , JSF 2.0. The examples
can be run in Java EE 5 Containers as well, with appropriate updates to the web.xml file.
Note:
The document describes setting up of the JSF example on local workspace, This documents uses
the following:
1)
2)
3)
4)
Eclipse IDE
Tomcat Version 7 Server
Maven Build
JSF Sun Reference Implementation (Mojarra Faces Implementation)
Source Code
Source Code for the examples are available if the following formats
1) Maven Project
This can be used to build the maven project and deploy to any Java EE Server.
The maven project can also be imported as a maven project, tweak the project facets to
be able to run as a Dynamic Web Application within any Java EE IDE with a compliant
servlet container.
2) Exported Project WAR
This can be either deployed to any Java EE Server, or be imported into a Java EE
complaint IDE and run as a Dynamic Web Application within IDE.
2 Eclipse
Following steps explain set up of Eclipse on local workstation.
This document uses Eclipse Helios v3.6
Download
Download Eclipse IDE for Java EE Developers from the following URL:
http://www.eclipse.org/downloads/
Extract
Extract the binary zip file to C:\ Drive
TIP: Add the Following lines to the eclipse.ini file based on available memory on the machine,
-Xms756m
-Xmx1024m
This is not a requirement but generally helps,
Start up Eclipse by running eclipse.exe, select workspace for the JSF examples
3 Tomcat
Following steps explain set up of Tomcat on local workstation.
This document uses Tomcat v7.0.12
Download
Download Tomcat from the following URL.
Note: Tomcat Server version 7.0.12 are used for the examples. Download the binary zip file
http://tomcat.apache.org/download-70.cgi
Extract
Extract the binary zip file to C:\ Drive
Configure
Update the tomcat users file under <Tomcat Server Install>/conf/tomcat-users.xml to add
users for accessing the host manager.
<role rolename="tomcat"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,admin-gui,role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
Validate
Validate that the server start up by running <Tomcat Server Install>/bin/startup.bat
Validate that Tomcat Manager is accessible, by clicking on the Manager App Link, enter the
username password configured in the tomcat users xml file.
You may use the tomcat manager to deploy the JSF application (WAR File).
9
4 Maven
(Note**: Only applicable if planning to use the maven web application project for JSF Examples)
Download
Download maven from the following URL, we are using Maven version 2.2.1
http://maven.apache.org/download.html
10
Extract
Extract Maven to C:\ Drive, need to set the <Maven Install>\bin to the Path so that the mvn
executable can be invoked from the command prompt.
Type mvn version on the command prompt to validate the maven install
Please consult maven documentation for further information, if inside a fire wall with no access
to the internet to the maven global repository, local repository may need to be set up and
versions of file may need to be installed manually.
11
Alternatively use the Eclipse Marketplace option available in Eclipse Helios , Select Help
Eclipse Marketplace option from the Menu and enter m2eclipse in the find input text box. Click
on Install for Maven Integration for Eclipse.
12
Extract the project source code and navigate to the Maven Project Folder.
From the Command prompt, navigate to the maven project and run mvn clean install to create
the war distribution,
This will create the war distribution under the target folder
13
The Maven Build will generate war file under Target folderas shown below,
14
Click on the hyperlinked JSFApps_Day1 in the manger app to launch JSF examples
15
Create an instance of the Tomcat Server in the workspace. Select the Server Tab and Select
New Server.
Note: If the Server Tab is not visible, select / click on Windows Show View Servers from
the Menu.
Select the appropriate Tomcat Server, (we are using tomcat v7.0.12 for the example)
Select the server and click on next.
16
Select the directory of the tomcat installation and click on finish to create the server
Start the Server to validate that the server work, right click on the server and select start, or
click on the start icon
17
18
Browse to the JSF Example war file and select the war file. Leave the rest default, click on next.
Click on Next
19
Do not select any jar files, these will be imported as part of WEB-INF/lib
20
21
By Default the Maven Project would be imported as a Java Project, we would need to add a
Dynamic Web Application Facet for it to allows us to easy build and deploy to locally running
server.
(There are other workarounds for these like running tomcat using Maven Tomcat Plug-in or
using the Maven Eclipse WTP Plug-ins, however to keep things simpler we will add project
facets externally to our project.)
M2Eclipse Plug-in allows to clean and install the project from menu options within Eclipse.
Select Maven Install to validate that the project builds within Eclipse using the M2Eclipse Plugin.
23
In order to facilitate running the Project on the locally installed Tomcat Server we would need
to copy required libraries to the WEB-INF/lib folder.
Copy Libraries from the Taget folder to the src/main/webapp/Web-Inf/lib folder.
Example:
C:\temp\temp\day1\MavenProject\JSFApp_Day1\target\JSFApp_Day1\WEB-INF\lib to
C:\temp\temp\day1\MavenProject\JSFApp_Day1\src\main\webapp\WEB-INF\lib
24
25
Select Dynamic Web Model Check Box and the Click on the Further configuration available
hyperlink.
27