|
What do we have in this session 8?
Running the Application
You are now finished coding the application. You can now test the application in your browser.
Right-click the project node in the Projects window and choose Run. When you choose Run, the IDE builds and deploys the application and opens index.xhtml in your browser.
|
If GlassFish web server failed as shown by the following message box, please rectify the problem.
You may need to start or restart GlassFish web server. From Services page > select GlassFish Server > right click mouse > Start/Restart.
---------------------------------------------
Make sure Java DB (Derby) database server was up and connected. The database used is sample. In Services page > select Java DB node > right click mouse > Start Server. Then re-run the project.
When all things are fine, the following are the sample outputs. Type a message in the text field. Click Post Message.
The following is the response page.
In order to close the project, select File > Close Project (project_name).
Many students asked about the following warnings, found when running the project more than once.
INFO: file:/C:/javaproject/SimpleEE6App/build/web/WEB-INF/classes/_SimpleEE6AppPU login successful
WARNING: Got SQLException executing statement "CREATE TABLE MESSAGE (ID BIGINT NOT NULL, MESSAGE VARCHAR(255), PRIMARY KEY (ID))": java.sql.SQLException: Table/View 'MESSAGE' already exists in Schema 'APP'.
WARNING: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'.
WARNING: Got SQLException executing statement "INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)": java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL110224034559950' defined on 'SEQUENCE'.
INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/SimpleEE6App'
The following is the screenshot.
Those are normal warnings when creating new table while the same table names are already existed. You need to delete the table before creating new one with the same name. When completing this project, we have set the data source to jdbc/sample as can be seen in persistence.xml file as shown below.
The database server used is Java DB (derby) and the database name is sample. We can view the sample database details from the Services page.
Select sample database from Java DB node > right click mouse > select connect. Make sure Java DB has been started.
If there are message that request username and password, please use 'app' as the username and password (this is the default username and password).
When the connection to sample database was successful, the connection can be seen as the in the following screenshot. Expand the connection string and the APP schema should be visible.
Expand the APP schema. The MESSAGE and SEQUENCE tables which were created in this tutorial should be visible.
------------------------------------------------------------------------------
In order to view the data that available in the table (if any), select a table, for example MESSAGE > right click mouse > select View Data context menu.
The following screenshot shows some sample data available in MESSAGE table.
To avoid the previous warnings, you can delete those two tables, every time you want to re-build and re-run the project.
Some of the sample database properties can be found in the JDBC connection pool as shown below.