Version 4

    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:

     

    1. download jsfexamples.zip to your local drive from http://www.oreilly.com/catalog/jsvrfaces

    2. unzip jsfexamples.zip into a directory which we will refer to as $EXAMPLE_HOME

    3. install JBoss 4.0.4 or higher into a directory which we will refer to as $JBOSS_HOME

    4. 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)

    5. 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)

      1. <listener>

      2.   <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

      3. </listener>

    6. 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)

      1. mike=manager

      2. hans=employee

    7. create the file $JBOSS_HOME\server\default\conf\users.properties if it does not exist and add the following two lines to it

      1. mike=boss

      2. hans=secret

    8. 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)

      1. from a Windows command prompt (you will find the jar executable in the \bin subdirectory of your JDK installation)

        1. cd $EXAMPLE_HOME\jsfbook

        2. jar -cvf jsvrfaces.war .

    9. start the JBoss server

    10. copy the .war file into the $JBOSS_HOME\default\deploy directory to deploy it

    11. navigate to http://localhost:8080/jsfbook/ 

    12. click on the Chapter 5 expense reports example

    13. login as username: mike password:boss

    14. you should see the expense report form