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.
- You have the Summit ADF source in a Oracle Developer Cloud Service project and building successfully as per Shay’s instructions.
- You have a Java Cloud Service instance to which you can deploy the Summit ADF sample application.
Step 1: Install the Summit ADF Schema
- Download and extract the Summit ADF schema.
- The scripts directory contains everything that is necessary to create the schema and populate it with sample data:
- 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;
- 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:
- Log into your Database Cloud Service Console to find your PDB Name. In my case it’s PDB1:
- 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:
- 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.
- In JDeveloper, expand Model > Application Sources > oracle.summit.model > services
- Open BackOfficeAppModule
- 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:
- Repeat for CustomerSelfServiceAppModule and SummitAppModule.
- Commit the changes:
- 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.
- Log into the WebLogic Administrative Console of your Java Cloud Service instance.
- 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.):
- 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):
- On the Transaction Options page, the defaults are fine:
- 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.
- On the Test Database Connection page, click Test Configuration:
- On the Select Targets page, select All Servers in the cluster and then click Finish:
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.
- In the Developer Cloud Service, edit the SummitBuild Configuration.
- Expand the Post-build Actions and check Archive the artifacts.
- Set the Files To Archive to SummitADF/ViewController/deploy/*
- Save and then click Build Now.
- 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
- 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:
- 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.
- 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:
- I’m going to delete all of these profiles and create a new profile of type Business Components Archive:
- I’m then going to delete the application profiles, and create a new deployment profile:
- 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
- Switch to the Pending Changes window:
- Add the changes:
- Commit the Changes:
- And Push the changes to the Developer Cloud Service (Git > Push).
- 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.
- In the Developer Cloud Service, Switch to the Deploy tab.
- Click New Configuration and fill in the details. I’ve configured the deploy to occur with each successful build:
- For the Java Service, you need to configure the remote target (Java Cloud Service):
- Supply the IP address of your Java Cloud Service instance along with your WebLogic server administration credentials (set when you created the JCS instance):
- Click Test Connection:
- Click Use Connection:
- Click Save, which will create the Deployment:
- Right-click the gear and select Start:
- Wait while the application is started:
- But unfortunately, deployment fails:
- 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://188.8.131.52/SummitADF-ViewController-context-root/faces/index.jsf.