Install and Use NetBeans 6.9 part 8

 

 

What do we have in this session 8?

 

  1. Running the Application

  2. Rectifying Some Errors

 

 

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.

 

NetBeans IDE: selecting the Java web application project, running the project

 

 

If GlassFish web server failed as shown by the following message box, please rectify the problem.

 

NetBeans IDE: selecting the Java web application project, the GlassFish web server failed

 

You may need to start or restart GlassFish web server. From Services page > select GlassFish Server > right click mouse > Start/Restart.

 

 

 

 

 

 

 

 

 

 

 

---------------------------------------------

NetBeans IDE: selecting the Java web application project, starting the GlassFish server from NetBeans IDE

 

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.

 

NetBeans IDE: selecting the Java web application project, sample output as seen in Browser

 

The following is the response page.

 

NetBeans IDE: selecting the Java web application project, the sample  response web page

 

In order to close the project, select File > Close Project (project_name).

 

NetBeans IDE: selecting the Java web application project, closing the project

 

Rectifying Some Errors

 

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.

 

The tables creation warnings

 

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 persistence.xml file containing the persistence settings

 

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.

 

Connecting to the sample database

 

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.

 

The jdbc derby database string connection

 

Expand the APP schema. The MESSAGE and SEQUENCE tables which were created in this tutorial should be visible.

 

 

 

 

 

 

 

 

 

 

 

------------------------------------------------------------------------------

Database tables seen from NetBeans Services page

 

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.

 

Viewing data in the table

 

The following screenshot shows some sample data available in MESSAGE table.

 

The data available in the table

 

To avoid the previous warnings, you can delete those two tables, every time you want to re-build and re-run the project.

 

Deleting the table in the database

 

 

Some of the sample database properties can be found in the JDBC connection pool as shown below.

 

Invoking the properties page of the SamplePool connection pool

 

 

The SamplePool connection pool properties page

 

 

 

 

 

< NetBeans and Java Web 7 | Java and Friends >


NetBeans and Java Web 1 | NetBeans and Java Web 2 | NetBeans and Java Web 3 | NetBeans and Java Web 4 | NetBeans and Java Web 5 | NetBeans and Java Web 6 | NetBeans and Java Web 7 | NetBeans and Java Web 8 | Java and Friends