Deploying an Application to Oracle Java Cloud Service - SaaS Extension

Overview

Purpose

This tutorial covers how to prepare an application for deployment and how to deploy it to Oracle Java Cloud Service - SaaS Extension.

Time to Complete

Approximately 30 minutes

Introduction

This tutorial shows how to check a sample Java web application with the Whitelist tool, a Java utility that prevents applications from using unsupported features. The tutorial then shows how to edit one of the application's deployment descriptors to ensure that the web application uses the previously provisioned Oracle Database Cloud Service. Finally, the tutorial shows how to deploy the application to Oracle Java Cloud Service - SaaS Extension by using the Java Cloud Services - SaaS Extension Control.

Scenario

This tutorial assumes that you are an Oracle customer. It also assumes that you have completed the Oracle by Example tutorial titled Signing Up for a Trial Oracle Java Cloud Service - SaaS Extension.

Prerequisites

Before starting this tutorial, you should :

  • Have an Oracle.com account.
  • Already completed the Oracle by Example tutorial titled Signing Up for a Trial Oracle Java Cloud Service - SaaS Extension.
  • Downloaded the sample Java web application visitors.war archive file. Download the file here: visitors.war.
  • Note for Internet Explorer Users: Internet Explorer may download visitors.war as visitors.zip. It is the same file. Just rename it visitors.war.

Downloading and Unzipping the Oracle Java Cloud Service - SaaS Extension SDK

In this section, you download and unzip the Oracle Java Cloud Service - SaaS Extension Software Development Kit (SDK), which contains the Whitelist tool.

  1. Open a web browser to the Oracle Cloud home page:
    https://cloud.oracle.com.

  2. From the Resources drop-down list, in the Support column, click for Developers.

    Download the SDK
  3. In the Downloads panel, click Oracle Cloud Downloads
    Download Link.
  4. Under Oracle Cloud Downloads and Java Cloud Service, click the Oracle Java Cloud Service - SaaS Extension SDK link.

    Oracle Cloud Downloads
  5. Under Oracle Java Cloud Service - SaaS Extension SDK, click the Download Oracle Java Cloud Service - SaaS Extension SDK link.

    Download Oracle Java Cloud Service SDK
  6. Select Accept License Agreement.

    Accept License Agreement
  7. Click the All Supported Platforms link to download the Oracle Java Cloud Service - SaaS Extension SDK to your local machine.

    Download for All Supported Plattforms
  8. On the Sign In screen, enter your Oracle.com username and password and click Sign In.

    Sign In
  9. After the file is downloaded, unzip it on your local machine to the <SDK_HOME> directory.

    Note: For this tutorial, the <SDK_HOME> directory is C:\oracle-javacloud-sdk.

Testing an Application for Disallowed Packages

Applications that are deployed to Oracle Java Cloud Service - SaaS Extension cannot use a few Java packages, such as java.rmi. In this section, you use the Whitelist tool to test an application for disallowed packages and verify if the application can be deployed.

  1. Open a command prompt and navigate to the lib directory under the <SDK_HOME> directory.

    lib directory
  2. Run the following command to see help information about the Whitelist tool:
    java -jar whitelist.jar -help

    Run Whitelist
  3. Run the following command to check the sample web application visitors.war archive file:
    java -jar whitelist.jar -l whitelist.log <APP_LOCATION>/visitors.war

    Note:

    • In this tutorial, the <APP_LOCATION> of the visitors.war archive file is the applications directory.
    • The whitelist.log file lists any usage violations that need to be corrected. In general, you can ignore warnings. If there are no violations, a message indicates that the validation was completed with zero errors.
    Check the archive file
  4. Examine the whitelist.log file in the current directory.

    The message indicates that the application can be deployed to Oracle Java Cloud Service - SaaS Extension.

    Log file

Ensuring That the Application Uses the Oracle Database Cloud Service

The sample web application in the visitors.war archive file uses the database to store information about visitors to a fictitious aquarium. Before deploying the web application, you need to edit its persistence deployment descriptor to ensure that it uses the Oracle Database Cloud Service that was provisioned when you signed up for Oracle Java Cloud Service - SaaS Extension.

  1. Perform the following steps to open the persistence.xml file:

    • Make a copy of the visitors.war file and rename it visitors.zip.
    • Unzip the visitors.zip file into a directory named visitors.
    • In the new visitors directory, expand WEB-INF > classes > META-INF.
    • Open the persistence.xml file in a text editor.
    persistence.xml file
  2. Perform the following steps to edit the persistence.xml file:

    • Scroll to the following line in the persistence.xml file: <jta-data-source><Database Cloud Service data source Name></jta-data-source>
    • Change the generic value of the <jta-data-source> tag to the name of the Oracle Database Cloud Service that was provisioned with your Oracle Java Cloud Service - SaaS Extension. In this tutorial, the database service name is javatrial6235db. With javatrial6235db inserted as the value of the <jta-data-source> tag, the XML is <jta-data-source>javatrial6235db</jta-data-source>.
    • Insert the following property within the <properties> tag: <property name="eclipselink.target-database" value="Oracle10g" />
    • Save the file. It should look like this:
    • Edit persistence.xml file
  3. Perform one of the following steps to create a new visitors.zip file:

    • WinZip: Zip the contents of the visitors directory into a new visitors.zip file. Include all subdirectories, but not their full path, and do not include the visitors directory itself. For example, if you examined the zip file in WinZip, the path of the fish.jpg file would be blank rather than visitors.
    • Command-Line Version of WinZip: Add the WinZip folder to the path (set PATH="C:\Program Files\WinZip";%PATH%). Change to the visitors directory, and then enter the following command to zip all files for recursion but not full path (-r -p), and include all files (*.*): wzzip -r -p visitors.zip *.*
      Zip the files
    • Mac Users: Download the WinZip Mac Edition, and then follow the steps for WinZip. Do not use the default Finder utility to zip the new archive file. If you do, extra files are placed in the archive, and they cause a 403 error when you try to access the application after it is deployed.
  4. Rename the new zip file visitors.war.

You will deploy this web application archive file next.

Deploying and Testing the Application

In this section, you deploy the application to Oracle Java Cloud Service - SaaS Extension and then test it.

  1. In a web browser, enter the URL for the Java Cloud Services - SaaS Extension Control.

    The link to this URL is in the welcome email that you received when you signed up for the trial Oracle Java Cloud Service - SaaS Extension. Look for Java Service Console in the Service Details section.

  2. Sign in with the service administrator's credentials.

    1. Enter the service administrator's username in the User Name field. In this tutorial, it is edgar.*******@*******.com.
    2. Enter the service administrator's password in the Password field.
    3. Enter the identity domain name in the Identity Domain field. You can find the name in the welcome email. In this tutorial, it is usoracletrial04861. (Your identity domain name will be different.)
    4. Click Sign In.
    Sign in to Oracle Cloud

    The Java Cloud Services Control for your Oracle Java Cloud Service - SaaS Extension is displayed.

  3. In the Applications section, click Deploy New.

    Java Cloud Services Control
  4. On the Deploy Application screen, enter visitors in the Name field, and click Browse to search for the application archive file.

    Deploy Application screen
  5. Browse to the location of the visitors.war file with the updated deployment descriptor, select the file, and click Open.

    The new visitors.war
  6. On the Deploy Application screen, click Deploy.

    Deploy Application

    After the file is uploaded, you are returned to the Java Cloud Services Control screen. The Information message indicates that the application was uploaded and will be deployed.

    Java Cloud Services Control 
                message
  7. Click the Reload button to refresh the page.

    The visitors application is eventually displayed in the Applications table.

    Java Cloud Services Control

    The green arrow in the Status column and the Active notation in the State column indicate that the deployment was successful.

    Java Cloud Services Control
  8. In the Test Application column, click the icon to access the deployed application.

    Applications window
  9. In the Application URLs pop-up window, click the URL for the application to display the application in another browser window or tab.

  10. Perform one of the following steps:

    • Skip to the next step if you are not asked to log in to the Java Cloud Services Control. (You are already logged in and your web browser uses one session ID for all open windows and tabs.)
    • Log in to this application with your service administrator's credentials and identity domain name. For login purposes in this tutorial, the login username is edgar.*******@*******.com, and the identity domain is usoracletrial04861.
    Sign in to Oracle Cloud
  11. On the first page of the sample application, click the Start link.

    Sample application

    Here's the screen that is displayed on the application's home page. This sample application enables you to add a name and comment about a fictitious aquarium. You can also update or delete visitor comments. The information is stored in Oracle Database Cloud Service.

    Welcome to the Plymouth Aquarium

Summary

In this tutorial, you learned to:

  • Use the Whitelist Java utility to check a sample application before deploying it
  • Modify the persistence.xml deployment descriptor of a sample application so that it uses Oracle Database Cloud Service
  • Deploy an application to Oracle Java Cloud Service - SaaS Extension by using the Java Cloud Services Control

Resources

Credits

  • Lead Curriculum Developer: Edgar Martinez
  • Curriculum Developer: Bill Bell
  • Editorial: Susan Moxley
  • Other Contributors: Reza Shafii

To navigate this Oracle by Example tutorial, note the following:

Topic List:
Click a topic to navigate to that section.
Expand All Topics:
Click the button to show or hide the details for the sections. By default, all topics are collapsed.
Hide All Images:
Click the button to show or hide the screenshots. By default, all images are displayed.
Print:
Click the button to print the content. The content that is currently displayed or hidden is printed.

To navigate to a particular section in this tutorial, select the topic from the list.