Automating Deployment of the Summit ADF Sample Application to the Oracle Java Cloud Service

Back in April, Shay Shmeltzer produced a video explaining how to automate the build of ADF applications using the Oracle Developer Cloud Service. Shay used the Summit ADF sample application for his example. In this article, I will take the next logical step and show you how to automate the deployment of the Summit ADF sample application to the Oracle Java Cloud Service.

Prerequisites

Step 1: Install the Summit ADF Schema

See the Instructions to install the schema for the full details. I will hit the highlights for installing the schema to the Oracle Database Cloud Service.

  1. Download and extract the Summit ADF schema.
  2. The scripts directory contains everything that is necessary to create the schema and populate it with sample data:
  3. We are going to run this script in our Database Cloud Service PDB. However, the create_user.sql as provided creates a common user (c##summit_adf), which must be created in the CDB (See Create User for details). Therefore, modify the create_user.sql script as follows:ALTER SESSION set container=CDB$ROOT;

    DROP USER c##summit_adf CASCADE;

    CREATE USER c##summit_adf IDENTIFIED BY summit_adf DEFAULT TABLESPACE users
    TEMPORARY TABLESPACE temp
    QUOTA UNLIMITED ON users;

    GRANT create session TO c##summit_adf container=all;
    GRANT alter session TO c##summit_adf container=all;
    GRANT create table TO c##summit_adf container=all;
    GRANT create trigger TO c##summit_adf container=all;
    GRANT create view TO c##summit_adf container=all;
    GRANT create sequence TO c##summit_adf container=all;
    GRANT create synonym TO c##summit_adf container=all;
    GRANT create type TO c##summit_adf container=all;
    GRANT create procedure TO c##summit_adf container=all;

  4. Secure copy the scripts directory to the oracle user home directory of your Database Cloud Service instance. I found it easiest to use a tool like WinSCP:
  5. Log into your Database Cloud Service Console to find your PDB Name. In my case it’s PDB1:newalphadbcs
  6. SSH into your Database Cloud Service instance as the oracle user and modify the connect string of the build_summit_schema.sql, replacing localhost with your PDB name:
  7. Log into SQL*Plus as the system user and execute the build_summit_schema.sql script

Step 2: Switch the Connection Type

We now need to switch the application connection type from JDBC URL to JDBC DataSource. For details about this step, you can read What You May Need to Know About JDBC Data Source for Oracle WebLogic Server.

  1. In JDeveloper, expand Model > Application Sources > oracle.summit.model > services
  2. Open BackOfficeAppModule
  3. Select Configurations and edit BackOfficeAppModuleLocal. Change the Connection Type from JDBC URL to JDBC DataSource. Also note the Datasource Name: java:comp/env/jdbc/summit_adfDS. We will need the next step when we create the Datasource in the Java Cloud Cloud Service:
  4. Repeat for CustomerSelfServiceAppModule and SummitAppModule.
  5. Commit the changes:
  6. Push the changes to your Developer Cloud Service project (Team > Git > Push).

Step 3: Create the JDBC DataSource

We need to create the data source our application is expecting to find. For details on this section see Creating a JDBC Data Source for Oracle WebLogic Server.

  1. Log into the WebLogic Administrative Console of your Java Cloud Service instance.
  2. Create a New Generic Data Source. Set the JNDI name to jdbc/summit_adfDS (Applications lookup a data source on the JNDI tree at java:comp/env/, so we exclude this portion of the Datasource Name. See Understanding JDBC Resources in WebLogic Server for details.):createnewjdbcdatasource
  3. On the JDBC Data Source Properties page, set the Database Driver to *Oracle’s Driver (Thin) for Service connections; Versions:9.0.1 and later (Fusion web applications are not compatible with data sources defined with the JDBC XA driver. See What You May Need to Know About JDBC Data Source for Oracle WebLogic Server for details):createnewjdbcdatasource2
  4. On the Transaction Options page, the defaults are fine:
  5. On the Connection Properties page, set the Database Name and Host Name from the Connect Descriptor found on your Database Cloud Service Console. This is the same page in Step 1-4 above where we grabbed the PDB Name. The Database User Name is c##summit_adf and the Password is summit_adf.
  6. On the Test Database Connection page, click Test Configuration:
  7. On the Select Targets page, select All Servers in the cluster and then click Finish:createnewjdbcdatasource6

Step 4: Create Deployment Artifacts

At the end of Shay’s video, we have a working build but no build artifacts:

In order to create a new deployment configuration, we need to configure our build to generate the artifacts. Looking at the Git Log from the previous build, you can see the location where the ear was generated:

[ora:ojdeploy] [06:24:38 PM] Deploying 2 profiles...
   [ora:ojdeploy]   file:/home/c2c/hudson/workspace/developer43881-wbrianleonard_cloudsandboxapplication.SummitBuild/ViewController/ViewController.jpr
   [ora:ojdeploy] [06:24:40 PM] Wrote Web Application Module to file:/home/c2c/hudson/workspace/developer43881-wbrianleonard_cloudsandboxapplication.SummitBuild/ViewController/deploy/SummitADF_ViewController_webapp1.war
   [ora:ojdeploy]   SummitADF_ViewController_webapp1:ViewController.jpr
   [ora:ojdeploy] [06:24:40 PM] Wrote Enterprise Application Module to file:/home/c2c/hudson/workspace/developer43881-wbrianleonard_cloudsandboxapplication.SummitBuild/SummitADF/ViewController/deploy/SummitADF_application1.ear
   [ora:ojdeploy] [06:24:40 PM] Elapsed time for deployment:  7 seconds
 [ora:ojdeploy] [06:24:40 PM] ----  Deployment finished.  ----

Note the EAR file is written to SummitADF/ViewController/deploy/SummitADF_application1.ear. Let’s configure our build to archive all artifacts in the SummitADF/ViewController/deploy/ directory.

  1. In the Developer Cloud Service, edit the SummitBuild Configuration.
  2. Expand the Post-build Actions and check Archive the artifacts.
  3. Set the Files To Archive to SummitADF/ViewController/deploy/*
  4. Save and then click Build Now.
  5. When the build completes, you’ll see the following artifacts:
    There are actually two EARs created, let’s return to JDeveloper to investigate.

Step 5: Investigate Deployment Profiles

    1. View the Summit ADF Application Deployment Properties (Application > Application Properties). Here you can see the two Deployment Profiles which map to our generated EAR files:
    2. If you look at the modules that make up each of these profiles, you’ll notice neither appear to have everything we need. Model_Summit_Interface:SummitADF_Application1:The Model_Summit_Interface has an reference to an EJB interface. I don’t believe the core version of this application has EJBs. The SummitADF_Application1 profile only references the ViewController, so that won’t work either. Let’s investigate further.
    3. View the Model project’s Deployment Profiles. We can see the deployment profiles that were available from the Application Assembly. However, none of these profiles seem to fit the bill, as this project is using ADF Business Components:
    4. I’m going to delete all of these profiles and create a new profile of type Business Components Archive:
    5. I’m then going to delete the application profiles, and create a new deployment profile:
    6. The new Application Deployment Profile will contain my new Model module as well as the existing ViewController module (which was OK):

Step 6: Commit and Push the Changes to Developer Cloud Service Project

  1. Switch to the Pending Changes window:
  2. Add the changes:
  3. Commit the Changes:
  4. And Push the changes to the Developer Cloud Service (Git > Push).
  5. The push will automatically trigger a Git build. When the build completes, we will have our single, complete, deployment artifact:

Step 7: Deploy Summit ADF to Java Cloud Service

Oracle Developer Cloud Service deploys applications to the Oracle Java Cloud Service server through an SSH tunnel. If not already configured, follow the steps at Installing the Oracle Developer Cloud Service Public Key in the Oracle Java Cloud Service VM to complete this one time exercise.

    1. In the Developer Cloud Service, Switch to the Deploy tab.
    2. Click New Configuration and fill in the details. I’ve configured the deploy to occur with each successful build:
    3. For the Java Service, you need to configure the remote target (Java Cloud Service):
    4. Supply the IP address of your Java Cloud Service instance along with your WebLogic server administration credentials (set when you created the JCS instance):
    5. Click Test Connection:
    6. Click Use Connection:
    7. Click Save, which will create the Deployment:
    8. Right-click the gear and select Start:
    9. Wait while the application is started:
    10. But unfortunately, deployment fails:
    11. Looking at the log file, we can see that:
      Target state: deploy failed on Cluster Alpha01J_cluster  weblogic.common.ResourceException: No credential mapper entry found for password indirection user=summit_adf for data source summit_adf

Step 8: Fix Deployment Error

Our problem (like all of our other problems thus far) is that the Summit ADF sample application is configured to deploy to JDeveloper’s Integrated WebLogic Server. If we revisit What You May Need to Know About JDBC Data Source for Oracle WebLogic Server, we need to disable the Auto Generate and Synchronize weblogic-jdbc.xml Descriptor During Deployment option. This option isn’t necessary because we switched the connection type from JDBC URL to JDBC DataSource.

After making, committing and pushing this change, the Summit ADF application will build and deploy successfully:

Step 9: Run

I’ve deployed this application to a single node JCS cluster without a load balancer, so we will hit the managed server directly. The URL is http://129.152.144.180/SummitADF-ViewController-context-root/faces/index.jsf.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s