The O'Reilly JavaServer Faces book by Hans Bergsten comes with a set of examples that you can download from http://www.oreilly.com/catalog/jsvrfaces (follow the Examples link to the author's home page).
The instructions in the book explain how to run the examples in a standalone Tomcat 5 instance, but with a couple of minor alterations they will run equally well in the Tomcat container integrated into JBoss AS 4.0.x.
The following steps show how to do this:
download jsfexamples.zip to your local drive from http://www.oreilly.com/catalog/jsvrfaces
unzip jsfexamples.zip into a directory which we will refer to as $EXAMPLE_HOME
install JBoss 4.0.4 or higher into a directory which we will refer to as $JBOSS_HOME
delete $EXAMPLE_HOME\jsfbook\WEB-INF\lib\jsf-api.jar and jsf-impl.jar (why? - the Sun default implementation of the JSF libraries bundled with the examples conflicts with the Apache MyFaces implementation in JBoss 4.0.x)
add the following lines to the end of $EXAMPLE_HOME\jsfbook\WEB-INF\lib\web.xml just before the closing </web-app> tag (why? - to inform the JBoss deployer that we will be using the Apache MyFaces implementation)
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
create the file $JBOSS_HOME\server\default\conf\roles.properties if it does not exist and add the following two lines to it (why? - these two files are the default way of configuring simple security in JBoss 4.0.x out-of-the-box)
mike=manager
hans=employee
create the file $JBOSS_HOME\server\default\conf\users.properties if it does not exist and add the following two lines to it
mike=boss
hans=secret
produce a .war file with all the subdirectories and files in $EXAMPLE_HOME\jsfbook (i.e. WEB-INF should be a first level directory in the produced .war)
from a Windows command prompt (you will find the jar executable in the \bin subdirectory of your JDK installation)
cd $EXAMPLE_HOME\jsfbook
jar -cvf jsvrfaces.war .
start the JBoss server
copy the .war file into the $JBOSS_HOME\default\deploy directory to deploy it
navigate to http://localhost:8080/jsfbook/
click on the Chapter 5 expense reports example
login as username: mike password:boss
you should see the expense report form
Comments