Java EE 8 SDK |
This is a JavaServer Faces 2.2 application that demonstrates a more complex example.
This sample demonstrates a more complex JavaServer Faces 2.2 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.
asadmin start-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.
app_dir
is the sample application base
directory: samples_install_dir/javaee8/jsf/scrumtoys
.
Change directory to app_dir.
mvn
target:
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
app_dir>
asadmin undeploy
<app_name>
clean
to remove the temporary directories
like /target.
app_dir> mvn
clean
This application uses a database. You must start the database service before deploying the application.
Use the following command to start the database:
asadmin start-database
Perform the following steps to build, deploy, and run the application using NetBeans IDE:
samples_install_dir/javaee8/jsf
directory, select scrumtoys
, select Open Required Projects, and click Open Project.scrumtoys
and select Run to build, deploy, and run the project.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:
asadmin start-database
Copyright © 2017 Oracle and/or its affiliates. All rights reserved.