Building and Testing Databound Web Applications using JCS, DBCS and JDeveloper 12c

Version 7

    The Cloud has become an integral part of the IT Ecosystem. Organizations are moving their huge physical IT infrastructure to the Cloud for better governance, lower TCO and better ROI. This article showcases the simplicity of using Oracle Java Cloud Service (JCS), Oracle Database Cloud Service (DCS) and JDeveloper 12c  to develop, deploy and test Web Applications


    By Kumar Shahi


    Highlights of this article:


    • How JDeveloper 12c eases the development of ADF Web Application
    • How JDeveloper 12c easily connects with JCS for smooth deployment
    • How SQL Developer easily connects to DCS and simplifies DB operations
    • No need to have a physical IT infrastructure to host your application as it uses JCS to host application
    • Access to diagnostic logs to have better monitoring and application testing


    This article covers:


    • Creating a simple DCS for hosting Application Schema
    • Creating Data Source in JCS to have access to DB Tables and data
    • Developing simple data-bound ADF Web Application using Jdeveloper 12c
    • Deploying and Testing Web Application on JCS
    • Accessing Diagnostic Logs via Putty




    • JDeveloper 12c (12.1.3.x)
    • Latest Oracle XE Database
    • SQL Developer 4.1 (with JDK 8)
    • Oracle Cloud Access (JCS and DCS)
    • Public/Private Key Pair to be used for account setup
    • HR Schema DDL
    • Putty

    Use Case


    I have taken a simple use case of creating an HR Application to show and modify employee information.


    In this exercise,


    1. Create Database Cloud Service
    2. Connect DCS using SQL Developer
    3. Set up HR User in DCS, create tables and populate data
    4. Develop HR Application using JDeveloper 12c
    5. Create datasource in JCS to connect HR Schema
    6. Set up Putty to tunnel JCS connection
    7. Set up JCS Connection using JDeveloper 12c
    8. Deploy HRApplication to JCS using JDeveloper 12c
    9. Access diagnostic logs using Putty




    Create Database Service


    Log in to Oracle Cloud Service at

    Supply Identity Domain,  User Name, User Password and Sign In.

    This dashboard page will open:


    Click "Open Oracle Database Cloud Service" to open the page below:


    Click the “Create Service” button to create a new Oracle Cloud Database Service. The page below will open. Select Service Level.

    The first option, Oracle Database Cloud Service, will be enabled only if the associated Oracle Cloud Storage Account has a container created and available.

    Otherwise, choose the Oracle Database Cloud Service-Virtual Image option.


    Billing Frequency needs to be specified even if you have a trial account. I have selected “Monthly."

    Click “Next.” You'll see this screen, where you can specify the database version:


    Click “Next” and select your Software Edition. I have selected Enterprise Edition.


    Click “Next.”


    Assign values to the required attribute:

    • Service Name – Specify Database Cloud Service Name
    • Compute Storage – Select configuration you would like to use
    • VM Public Key – Supply Public Key (created as part of prerequisite)
    • Usable Database Storage – Specify storage requirement for the database service
    • Total data file storage – Specify total data file storage
    • Administration Password – Specify Password for the SYS user
    • Confirm Password specified above
    • DB (Database) name – Automatically populated. User can modify if required.
    • PDB (Pluggable Database) Name – Automatically populated. User can modify if required.
    • Backup destination –  The “Both Cloud and Local Storage” option will  be available only if container is configured. Otherwise, user can select “Local Storage Only.”
      If backup destination is “Both Cloud and Local Storage,”  user will have to supply:
      • Cloud Storage Container – e.g., identityDomainName/containerName
      • Cloud Storage User name – cloud admin user name (normally email id)
      • Cloud Storage Password – cloud admin password.

    Click “Next.” Confirm on the landing page to start creation of DBaas Service.

    Database Cloud Setup Progress

    It may take a few minutes to set up Database Cloud Service. Click “Service Name” to see the list of activities being performed.


    Connect Database Service using SQL Developer


    This requires two steps: Setting up SSH and Creating New Database Connection.


    Setting up SSH


    Start SQL Developer 4.x.


    Open the “View” menu and click “SSH”. It will open the SSH Panel in SQL Developer.


    Right click “SSH Hosts” and add “New SSH Host”:


    In the above screen, specify attribute values as given below:

              Name – Specify Name of your choice. (Tip: Specify name based on Oracle DB Cloud Service Name so that it will be easy to remember.)

              Host – Host must be the Public IP of Oracle Database Cloud Service

              Port – Leave as 22

              User Name – Must be oracle

        • Check “Use Key File” checkbox and browse “Private Key file” generated as part of prerequisite.

    Check “Add a local port forward" to set Local Port Forward details as below,

              Name - Specify any Name of your choice

              Host – Must be Public IP of Database Service

              Port – Port specified for your Database Service (e.g., 1521)

        • Check “Automatically assign local port”

    Now, right click on this new SSH Host and click “Connect.”

    Creating New Database Connection


    Go to “Connections” and right click “New Connection”:


    You'll see this screen, where connection details will be supplied:


    In the above image, specify properties as given below:

    Connection Name – Specify any logical name

    User Name – The Administrator User Name specified while setting up Oracle Cloud Database Service, e.g. SYS.

    Password – Password specified for the Administrator

    Select Connection Type – SSH

    Role – SYSDBA

    Port Forward – When you select Connection Type = “SSH,” Port Forward will list the “SSH Host Name” you created. Select SSH Host Name set up as part of "SQL Developer SSH Setup."

    Specify SID – Generally, ORCL (unless you changed it)

    Click the “Test” button. You'll see “Success.”

    Click “Save” to save this connection and use it just like another DB connection.

    Setting Up HR Schema

    Open the SQL worksheet and run the commands below:


    Create a new Database Connection using c##hr user. Follow the same steps as you followed in "Creating New Database Connection," above, except specify Role = Basic.

    Set up HR Schema using HR_30.sql, which can be downloaded from the location below. Recompile Triggers if it throws any error.

    Download HR Schema from:

    Extract zip file and run SQL to set up HR Schema.

    Scripts to load data can be found in the attachment of this article. Alternatively, you can export data from your local HR Schema and use those scripts.

    Loading data into tables

    Disable Trigger SECURE_EMPLOYEES (it validates against normal office hours to insert/update employee data). Run scripts in the following sequence:





    Disable constraint DEPT_MGR_FK from DEPARTMENTS Table before running departments.sql:






    Enable constraint DEPT_MGR_FK from DEPARTMENTS Table again.

    Creating HRApp Web Application

    Open JDeveloper 12c. Select "New"->"Applications"->"Fusion Web Application", Click OK.



    Specify Application Name "HRApplication" and Application Package Prefix "com.hrapp":


    Continue with default options until you reach the page depicted below and Click "Finish". It will create HRApplication ADF Web Application.


    Create Business Objects using HR Schema. Right Click on "Model" Project and select "New":

    Select "Business Components from Table" and click "Next".  It will open "Create Database Connection."

    Remember, the connection above is made to a local instance of HR Schema installed on my local machine.

    Create a new connection with the name "hrconn," with access credentials as below:


    In the next step, the newly created connection will be automatically selected. Select "OK":


    Hit "Auto Query" to list available entities.

    Select Employee and Departments table from available entities and move them to selected pane as given below.

    Rename default package name "com.hrapp.model"(As displayed in below image) to "com.hrapp.entities".

    Select each table name and rename their Object Name to EmployeesEO and DepartmentsEO respectively and select "Next".


    Move all available entities to selected pane.

    Rename default view package to "com.hrapp.views" as shown below.

    Select each entity and change their name from,

         "DepartmentsEOView" to DepartmentsVO

          and "EmployeesEOView" to EmployeesVO

         then click "Next".


    Continue with default selection until you reach the "Application Module" page. Rename AppModule Name "HRAppModule" and the package name to "" and then Select "Finish".


    The Model Project will look like the figure, below, where all entities, View Objects and an App Module will be created. There is a default DataControl also created to access services.


    Create Web Page to display Employee Data and Modify information.

    Select "View Controller" Project ->Web Content" -> "New":


    Select "JSF Page" from the dialog and Click "OK."

    You'll see the popup below. Specify File Name = "empDetail.jspx", Document Type="JSP XML" and Page Template = "Oracle Three Column Layout." Click "OK."


    It will create empDetail.jspx page.

    Select the "End" section from the "Structure" panel and delete it.

    Expand "HRAppModuleDataControl" and drag "DepartmentsVO1" to the "Facet Start" section and create as ADF Form.

    Remove "Employee ID" from the display list and Select "Navigation Button" check box from the dialog box.

    Click "OK."



    Select "Facet:Center" and add "Panel Splitter" to "Facet:Center."

    Expand "Panel Splitter -> Start."

    Drag "DepartmentVO1"-> "EmployeeVO3" to "Panel Splitter->First" section, and drop as Read-Only Table.

    Drag "DepartmentVO1"-> "EmployeeVO3" to "Panel Splitter->Second" section, and drop as ADF Form.

    It will look like this:


    Select "Single Row" to allow single row selection in table.

    Check "Enable Sorting" to enable Sorting of data based on each columns ascending/descending.

    Check "Enable Filtering" to enable filtering records using column filter.


    Surround Departments ADF Form, Employees ADF Form and Employees ADF Read-only Table with ADF Panel Box.

    Change Panel Box names to,

    "Departments" for Departments ADF Form,

    "Update Employees Information" for Employees ADF Form

    and "Employees List" for Employees ADF Read-only Table respectively.

    Select af:PageTemplate from empDetails.jspx - Structure Panel. In the Property Inspector window, change "Start Column Size" to 350.

    Select "Save All."

    Create Datasource for Web Application

    Log in to JCS.

    Open the Service Console, as shown below,

    Open the WebLogic Server Console from here.

    In the left panel, click "Services," then "Data Sources." Click “Lock & Edit” to enable “New” Button.


    Then click “New->Generic Data Source.”


    Name = use any logical name

    JNDI Name = This could be anything (I have specified “jdbc/hrds” and Oracle Database Cloud Service Name)

    Database Type = Oracle

    Click “Next.”


    On the next screen, "JDBC Datasource Properties," simply click "Next."


    The "Transaction Options" screen will open. Click "Next;"


    Enter details as mentioned in below screen,

    Database Type = Oracle

    Database Driver = As specified above. You can choose these setting based on your DB and driver.

    On the next screen, “Simply click “Next”. It will open the screen below:

    Database Name = ORCL, unless you changed it while creating database Cloud Service Instance

    Host Name = Enter your Database Cloud Service name

    Port = 1521

    Database User name = c##hr (HR Schema user name)

    Password = Welcome#1 (specified for HR Schema)

    Click “Next.”


    On the next page, click “Test Configuration.” It should be a success.

    If it doesn't show successful then re-verify the credentials supplied for database connection. Also make sure that network connection is there to connect to Database Cloud Service.


    Select Managed Server Name "kumarjav_server_1" and Click “Finish."


    Set Up SSH for Java Cloud Service

    Make sure you have set up Oracle Java Cloud Service.

    Start Putty by clicking on putty.exe


    Specify Host Name – Public IP of Oracle Java Cloud Service Instance

    Make sure Connection Type = SSH

    Specify Saved Session name = Any name (it's best to use a meaningful name based on IP/Service connected)

    Expand “Connections from left panel and select “Data,” as shown below:


    Login details > Auto-login username = opc

    Select “Connection->SSH” from left Panel, as shown below:


    Select “Don’t start a shell or command at all” in Protocol options.

    Select “Connection->SSH->AUTH” from left panel, as shown below:


    Browse and supply the private key generated as part of the prerequisites.

    Select “Connection->SSH->Tunnels” from left panel, as shown below:


    Source port = 9001 This is specially configured for SSH-based access.

    Specify Destination = Java Cloud Service Public IP:9001. Click “Add.”

    Select “Session” from the top of the left panel. Click “Save” and then "Open." You'll see a console like this:


    Now you can use your JDeveloper to connect to JCS.

    Connect JCS using JDeveloper

    Open JDeveloper (I used JDeveloper 12.1.3.x).

    Go to the “Window” Menu and select “Application Servers.” to display the Application Servers Panel.


    Right Click on Application Servers, then New Application Server:


    Select “Standalone Server" from the screen below:


    Connection Name = Any name.

    Connection Type = Weblogic 12.x, as shown below:


    Supply the Username and Password that you created for WebLogic Connection while setting up JCS Connection:


    WebLogic Hostname = localhost

    Port = 9001

    WebLogic domain = domain copied from WebLogic console.


    Click “Test Connection”; you'll see the following screen. All connections return "success." Click “OK” and use this WebLogic server connection for deployment, etc., activities from JDeveloper directly.


    Deploy HRApplication using JDeveloper

    Select "Application" menu -> "Deploy" -> "HRApplication_Project1_HRApplication


    Select "Deploy to Application Server" and Click "Next."


    Select "CloudServer" and click "Next."


    Select the managed server where the application is to be deployed, as shown below:


    Now, it will search for missing libraries and list if any.

    If there are missing libraries listed, make sure checking "Automatically Install Required Shared Libraries". I had no missing library so it is not selected in below image.

    Click "Next."


    Hit "Finish" to deploy it to the server. It will take a few minutes and reflect status in the JDeveloper console.


    You can now access your application using this link:

    http://<Server Public IP>/HRApplication-ViewController-context-root/faces/empDetail.jspx

    It will look like this:


    Access JCS Logs

    • Run Putty with JCS Tunnel Settings
    • From the Putty console, run this command:


    >sudo su – oracle

    It will switch current “opc” user to super user “oracle”.

    • Now you can go to the WebLogic logs folder and check the log using this command,

    >tail -f logFileName.out

    Then run your application again. The Putty console will show real-time logs.


    Oracle Java Cloud and Oracle Database Cloud support easy integration with JDeveloper 12c (12.1.3.x) for development, deployment and testing web applications. It lets the user simplify development and deployment activities while reducing the organization's operating challenge by moving everything to the cloud. Oracle Cloud can be easily extended to support more and more users by increasing physical support using simple clicks. Oracle Java Cloud allows hosting full-fledged web applications just like another WebLogic Application Server, whereas Oracle Database Cloud supports full-fledged database features for any kind of high-scale support.

    About The Author

    Kumar Abhishek Shahi works with Oracle as an Architect specializing in ADF, WebCenter Suite, Portal integrations with SOA, BPM and Apps, MAF, Big Data and Oracle Cloud. He is part of the Digital Experience Team, where he contributes in Solutioning, Architecture, Feature Enhancements, Migrations and Upgrades. He is an active blogger, a speaker at various industry forums, and a mentor.