Java EE 8 SDK 

Samples Main Page

The ScrumToys JSF Sample Application

This is a JavaServer Faces 2.2 application that demonstrates a more complex example.

Description

This sample demonstrates a more complex JavaServer Faces 2.2 application.

Key Features

Building, Deploying, and Running the Application

This application uses authentication and a database. You must configure the authentication and start the database service before deploying the application.
Use the following sequence of commands to configure authentication as expected by the app:

Let the text file userpassword.txt contain the following text only:

AS_ADMIN_USERPASSWORD=user1

Execute the following commands using asadmin

asadmin set server.security-service.activate-default-principal-to-role-mapping=true 
asadmin --passwordfile userpassword.txt delete-file-user user1 
asadmin --passwordfile userpassword.txt create-file-user --groups user user1  

If the user1 user does not exist, the delete-file-user command will fail. This failure is expected and can be safely ignored.


Use the following command to start the database:

Note: To remove the database created by this application, shut down the app server with asadmin stop-domain domain1 and the database with asadmin stop-database and then delete the sun-appserv-samples directory within the glassfish4/glassfish/databases directory.

Following are the instructions for building, deploying, and running this sample 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/javaee8/jsf/scrumtoys.
  3. Change directory to app_dir.
  4. Build, deploy, the sample application using the mvn target:
  5.         app_dir> mvn install

           To deploy the project, you can go to app_dir and use the command line below:

            app_dir> asadmin deploy ./target/scrumtoys.war

  6. Use the glassfish command line to undeploy the application.

    app_dir> asadmin undeploy <app_name>

  7. Use the target clean to remove the temporary directories like /target.

    app_dir> mvn clean

Building, Deploying, and Running the Application in NetBeans IDE

This application uses a database. You must start the database service before deploying the application.
Use the following command to start the database:

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 8 SDK.
  2. In the NetBeans IDE, choose File → Open Project (Ctrl-Shift-O), navigate to the samples_install_dir/javaee8/jsf directory, select scrumtoys, select Open Required Projects, and click Open Project.
  3. In the Projects tab, right click scrumtoys and select Run to build, deploy, and run the project.

Troubleshooting

If you see the error Error on try to save Project, the database service may not be running.

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. To remedy the problem of not being able to save a project, follow these steps:

  1. Run the following command: asadmin start-database
  2. Repeat Step 4 above (Building, Deploying, and Running The Application).

Copyright © 2017 Oracle and/or its affiliates. All rights reserved.