Compile and Run application with GlassFish applicaton server


IMPORTANT PRE-REQUISITES

1. Set up environment to compile and run the sample application

The following script must be run for each of the terminal session:

Windows:   > quickstart/ttquickstartenv.bat
Unix/Linux:   $ . quickstart/ttquickstartenv.sh OR
$ source quickstart/ttquickstartenv.csh

2. Set up sample database, user accounts and the TPTBM table

The following command should be run once to set up the sample database, user accounts and the TPTBM table.

Windows or Unix/Linux:   > cd quickstart/sample_code/j2ee_orm
> ttIsql -connStr "DSN=sampledb_1122" -f tptbm.sql

3. If necessary, install the Apache Ant build tool.

For each application server, an Ant build script is provided to configure, build and execute the application based on the properties of the applicaton server installation. The Apache Ant build tool has to be installed if not present.

After installation, make sure the Operating System environment variable PATH includes the path to the 'ant' executable.

The Ant build scripts have been tested with Apache Ant version 1.9.2.

  

CONFIGURE AND RUN

1. install GlassFish application server and configure build.properties

Install GlassFish Server 3 and then set the following properties in file quickstart/sample_code/j2ee_orm/build.properties:

    glassfish.home.dir   -- set this to the root installation directory
                            of the local GlassFish server installation

    glassfish.domain.dir -- the location of the domain directory for the 
                            server hosting the Tptbm application

    glassfish.deploy.dir -- the directory where application archives can be
                            copied and auto deployed to the server
                              
    glassfish.host       -- the host name of the machine where the server is
                            installed

    glassfish.orb.port   -- the RMI port number used by external clients to 
                            communicate with the server, the default port
                            number is 3700
Each Ant build script reads values from file quickstart/sample_code/j2ee_orm/build.properties. This file specifies the locations of build dependencies including the location of the application server installation. This file also specifies the common benchmark execution parameters.

2. TimesTen JDBC Driver

The server will require access to the TimesTen JDBC driver jar file. This can be done by copying the TimesTen JDBC driver jar file from the TimesTen installation's lib directory into the ${glassfish.domain.dir}/lib directory.

3. LD_LIBRARY_PATH

The server will also need access to the TimesTen shared libraries. This can be done by setting the LD_LIBRARY_PATH environment variable (or the equivalent variable for your OS) to the location of the TimesTen installation's lib directory. On Windows platforms the PATH environment variable should be set to the location of the installation's bin directory where TimesTen DLLs are located.

4. TimesTen Data Source

Before the application can be deployed or executed, a TimesTen connection pool and a JDBC data source with the JNDI name of jdbc/TbtbmDS must be configured on the server. Follow these steps:

  1. Connect to the GlassFish Server administration console. By default a local server's administration console can be accessed at http://localhost:4848.

  2. Select Resources->JDBC->Connection Pools from the left hand pane. Click the 'New...' button.

  3. At the 'New JDBC Connection Pool (Step 1 of 2)' screen enter 'TptbmPool' in the 'Name' field.
    In the 'Resource Type' drop down list box select 'javax.sql.ConnectionPoolDataSource'.
    In the 'Database Vendor' field enter 'Oracle TimesTen'. Click 'Next'.

  4. At the 'New JDBC Connection Pool (Step 2 of 2)' screen enter 'com.timesten.jdbc.ObservableConnectionDS' in the 'Datasource Classname' field.
    Scroll down to the 'Additional Properties' section at the bottom of the screen.
    Click the 'Add Property' button. A new row will appear.
    Click the check box in the new row. Type 'url' in the 'Name' column. In the 'Value' column enter 'jdbc:timesten:direct:sampledb_1122'.
    Click the check box for the 'password' property and in the 'Value' column type 'tiger'.
    Click the check box for the 'user' property and in the 'Value' column type 'SCOTT'.
    Click the 'Finish' button.

  5. Select Resources->JDBC->JDBC Resources from the left hand pane. Click the 'New...' button.

  6. At the 'New JDBC Resource' screen enter 'jdbc/TptbmDS' in the 'JNDI name' field. In the 'Pool Name' field select 'TptbmPool'. Click 'OK'.

  7. The server should be restarted in order for the configuration changes to take effect.

5. build, deploy and run the sample application

After the server has been configured to use the jdbc/TptbmDS data source and restarted, the application can be built, deployed, and executed, through Ant script build-glassfish3.xml, with this sequence of Ant tasks under directory quickstart/sample_code/j2ee_orm:

   ant -f build-glassfish3.xml clean
   ant -f build-glassfish3.xml package
   ant -f build-glassfish3.xml deploy
   ant -f build-glassfish3.xml run
   

Note that this application has been tested with GlassFish Server 3.0.1, and GlassFish Server 3.1.2.2.

 

TROUBLESHOOTING

 

For more information on Java programming with Oracle TimesTen, refer to the Oracle TimesTen In-Memory Database Java Developer's Guide.