Java EE 6 SDK

Samples Main Page

# The JSF 2.0 Complete Sample Application

This sample application shows the use of many new features in JavaServer Faces 2.0. These features include Facelets (including templating), Ajax, new simplified Facelets tag library syntax, composite components, implicit navigation, and more. Data is stored and retrieved via JPA.

## Building, Deploying, and Running the Application

Perform the following steps to build, deploy, and run the application:

1. Set up your build environment and configure the application server with which the build system has to work by following the common build instructions.
2. `app_dir` is the sample application base directory:`samples_install_dir/javaee6/web/jsf/scrumtoys/`.
3. ````Change directory to `app_dir.
   `
4. Build, deploy, and run the sample application using the `all` target.``

`app_dir> ant all`

You can replace the `ant all` command with the following set of commands:

`app_dir> ant default` compiles and packages the application

`app_dir> ant deploy` deploys it to application server

`app_dir> ant run` runs the test java client

5. Use the target clean to undeploy the sample application and to remove the temporary directories such as build and dist.

   `app_dir> ant clean`

## Building, Deploying, and Running the Application in NetBeans IDE

Perform the following steps to build, deploy, and run the application using NetBeans IDE:

1. Refer to the common build instructions for setting up NetBeans IDE and Java EE 6 SDK.
2. In the NetBeans IDE, choose File → Open Project (Ctrl-Shift-O), navigate to the `samples_install_dir/javaee6/web/jsf/` directory, select `scrumtoys`, and click Open Project.
3. In the Projects tab, right click `scrumtoys` and select Run to build, deploy, and run the project.

## Troubleshooting

In case of receiving "Error on try to save Project" check if database is up.
The domains/domain1/log/server.log file may contain the following errors:

    [#|2009-05-14T23:23:17.140-0700|SEVERE|glassfish|org.eclipse.persistence.session
    .file:/C:/sdk/glassfish/samples/javaee6/web/jsf/scrumtoys/build/web/WEB-INF/clas
    ses/-scrumtoysPU.ejb|_ThreadID=18;_ThreadName=Thread-1;|
    Local Exception Stack:
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20090424-r40
    50): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cau
    se: Connection could not be allocated because: java.net.ConnectException : Error
     connecting to server localhost on port 1527 with message Connection refused: co
    nnect.

    or

    [#|2009-05-14T16:37:52.578-0700|WARNING|glassfish|org.eclipse.persistence.sessio
    n.file:/C:/sdk/glassfish/domains/domain1/applications/scrumtoys/WEB-INF/classes/
    -scrumtoysPU|_ThreadID=15;_ThreadName=Thread-1;|
    Local Exception Stack:
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20090424-r40
    50): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLSyntaxErrorException: Table/View 'PROJECTS' does
     not exist.

Once the scrumtoys application is deployed while database is down, bringing database up will not fix the problem. Restarting glassfish does not help either. The only way to get the scrumtoys application working properly is to have the database up before *deploying* the application. Thus to remedy the problem with not being able to save a project one needs to do the following:

1. asadmin start-database
2. ant clean
3. ant run

If you still have problems when running the application, refer the troubleshooting document.

Copyright © 1997-2010 Oracle and/or its affiliates. All rights reserved.