Creating a Project from a Template and Deploying It to Oracle Application Container Cloud Service


Options



Before You Begin

Purpose

In this tutorial, you'll learn how to create a Java web application in Oracle Developer Cloud Service using a template, populate the repository, then deploy the application to Oracle Application Container Cloud Service.

Time to Complete

Approximately 25 minutes

Background

Oracle Application Container Cloud Service provides a lightweight infrastructure so that you can run Java SE 7, Java SE 8, and Node.js applications in Oracle Cloud, and it can be integrated with other Oracle Services, such as Oracle Developer Cloud Service, to complement the development process.

Oracle Developer Cloud Service is a cloud-based software development Platform as a Service (PaaS) and a hosted environment for your application development infrastructure. It provides an open source standards-based solution to develop, collaborate, build, and deploy applications within Oracle Cloud.

Scenario

You will create a project from an Oracle Developer Cloud Service template. The project contains the code for a deployable web application. To learn how to create the application used in this tutorial, see the OBE tutorial Creating a Web App with Bootstrap and Tomcat Embedded for Oracle Application Container Cloud Service. The application is a simple Java web application of employees that implements the CRUD (Create, Read, Update, and Delete) operations. The application uses Bootstrap to add User Interface styles, Tomcat as the embedded server, and Maven to compile and package the dependencies needed to run a standalone web application.

The project code contains two Maven scripts to compile and package the application:

  • The pom.xml file, located in the project root directory. It contains all the dependencies to compile and run the application.

    The Maven Assembly Plugin (maven-assembly-plugin) allows users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable archive, employees-app-1.0-SNAPSHOT-jar-with-dependencies.jar. The pom.xml file is configured to execute an assembly descriptor, distribution.xml.

  • The distribution.xml file, located in the src\assembly directory. It creates a zip file (employees-app-1.0-SNAPSHOT-dist.zip) that contains the the manifest.json file. You deploy this ZIP file to Oracle Application Container Cloud Service. The manifest.json file contains additional environment configurations for Oracle Application Container Cloud Service.

You'll deploy the ZIP file, then clone the project locally, make a change to the code, commit the change to the Oracle Developer Cloud Service Git repository, and finally rebuild and redeploy the project.

What Do You Need?

  • An active Oracle Cloud account that includes an instance of both Oracle Developer Cloud Service and Oracle Application Container Cloud Service
  • A local Git instance

Creating a Project and a Git Repository in Oracle Developer Cloud Service

  1. Launch your Oracle Developer Cloud Service, following the instructions in "Accessing Oracle Developer Cloud Service Using the Web Interface" in Using Oracle Developer Cloud Service.

  2. Provide your identity domain, user name, and password, and click Sign In. Then, from the Dashboard, click Developer, then click Open Service Console.

  3. On the Welcome page, click New Project.

    Welcome page
    Description of the image
  4. On the first page of the New Project dialog, enter a name for the project, such as My Web Application. In the Description field, enter a description, such as Web application. Select Private as the Security setting, then click Next.

    Project Details page of New Project wizard
    Description of the image
  5. On the Template page, select ACCS Java SE Sample with Deployment, and then click Next. (Your instance may have different templates.)

    Template page of New Project wizard
    Description of the image
  6. From the Wiki Markup drop-down menu, select MARKDOWN (the default), then click Finish.

    Project Properties page of New Project wizard
    Description of the image
  7. Wait for provisioning to complete.

    Project provisioning page
    Description of the image

    After provisioning completes, the project is fully provisioned. You are on the project's Home page, which displays the URLs of the Git and Maven repositories. The activity feed reports the creation of the project, the repository, and a README page, along with the creation of the repository from the template you selected.

    Project page of newly created project
    Description of this image

Examining the Oracle Developer Cloud Service Project

  1. From the project Home page, click the Code tab to view the newly created repository. The template has populated the repository with a web application named employees-app and an explanatory README file. If you wish, click employees-app and open the application's subdirectories to view the application structure.

    Code page
    Description of this image
  2. Click the Wiki tab, then click the link to the wiki page that provides more information.

    Wiki Home page
    Description of this image

    The wiki page contains sections titled "Introduction," "Build and Package," "Deploy," and "Additional Resources."

    Application README wiki page
    Description of this image
  3. Click the Build tab, then click employees-app-build to view the project's build job.

    Jobs Overview page
    Description of this image
  4. The build job is displayed. No builds have taken place yet. Click Configure to view the build configuration.

    Build job page
    Description of this image

    The Main tab displays the build job name, description, and JDK.

    Main tab of Configure build job page
    Description of this image
  5. Click Source Control to view the Git repository settings for the build.

    Source Control tab of Configure build job page
    Description of this image
  6. Click Build Steps to view the Maven goals and POM file for the project.

    Build Steps tab of Configure build job page
    Description of this image
  7. Click Post Build. The build artifacts will be archived. Finally, click the Cancel button.

    Post Build tab of Configure build job page
    Description of this image

The next tasks are to build the project and deploy it to Application Container Cloud Service.

Building your Application on Oracle Developer Cloud Service

In this section, you build the application, using the build job provided in the template, to generate the artifacts needed to deploy the application to Oracle Application Container Cloud Service.

  1. In your Oracle Developer Cloud Service console, click the Build tab, and then click employees-app-build.

  2. On the job page, click Build Now.

    Build Now button on job page
    Description of the image

    The build is queued.

    New Build Queued notification
    Description of the image

    Then the job is building.

    New Build progress bar
    Description of the image

    Soon, the build is completed.

    Completed job in Build History table
    Description of the image

    The artifacts are displayed: a zip file, a JAR file, and a WAR file. Expand the employees-app and target nodes to see them.

    Job Artifacts display
    Description of the image

Deploying the Application to Oracle Application Container Cloud Service

  1. Click the Deploy tab, and then click New Configuration.

    Empty Deploy page with New Configuration button
    Description of the image
  2. In the New Deployment Configuration page, enter values in the following fields, and then click Save and Deploy.

    • Configuration Name: employees-app
    • Application Name: employees-app (automatically populated)
    • Deployment Target: Select the identity domain of your Oracle Application Container Cloud Service (and accept the default ACCS properties). If an ACCS target is not in the list, click New, select Application Container Cloud, enter the values for your instance in the Deploy to Application Container Cloud dialog box, and click Test Connection. When the connection succeeds, click Use Connection.
    • Type: On Demand
    • Job: employees-app-build
    • Build: 1 (Success)
    • Artifact: employees-app/target/employees-app-1.0-SNAPSHOT-dist.zip (the ZIP file, not the WAR file)
    New Deployment Configuration page
    Description of the image

    The deployment configuration appears on the Deployments page, with an indication that the creation succeeded. The deployment is running.

    Completed deployment configuration
    Description of the image

    After some time, the deployment succeeds.

    Deployment success and history
    Description of the image
  3. The application name is now a link. Click the application name (employees-app) to execute the application. The application opens in a separate tab or window.

    Application name link on Deployments page
    Description of the image

    Now you can see your application running in Oracle Application Container Cloud Service.

    Employees application page
    Description of the image

Cloning the Project

Before you can make changes to the project code, you'll need to clone the project to create a local copy of the project code to work with.

  1. Expand the Administration tab, then click the Repositories tab.

    Repositories tab under Administration tab
    Description of this image
  2. The Git repository URL is displayed in the Hosted Repositories area under the repository name. Select and copy the URL.

    Repository URL on Repositories page
    Description of this image
  3. On your local system, open a command window that provides access to Git commands, such as Git Bash. Change to the location where you want to clone the project.
  4. Issue a git clone command, pasting the URL you copied as the argument. Your command line will have its own service URL and organization name. You'll be asked for your password.

    $ git clone https://user-name@service-url/org-name/s/org-name_my-web-application_nnnnn/scm/employee-app.git
    Cloning into 'employee-app'...
    Password for 'https://user-name@service-url':
    remote: Counting objects: 51, done
    remote: Finding sources: 100% (51/51)
    remote: Getting sizes: 100% (48/48)
    remote: Total 51 (delta 2), reused 51 (delta 2)
    Unpacking objects: 100% (51/51), done.
    Checking connectivity... done.
    Checking out files: 100% (33/33), done.

Updating your Application

In this section, you make a change in your application, commit, push, build, and watch your updated code deployed to Oracle Application Container Cloud Service.

  1. On your local system, open the file employees-app\src\main\webapp\jsp\list-employees.jsp in a text editor.

  2. Change the title <h2>Employees</h2> to <h2>My Employees Application</h2> and save the file.

  3. In the Git Bash or terminal window, go to the employee-app directory add the updated file into the Git repository index.

    $ git add employees-app/src/main/webapp/jsp/list-employees.jsp
  4. Commit the changes.

    $ git commit -m "Title updated"
    [master 8db98d6] Title updated
     1 file changed, 1 insertion(+), 1 deletion(-)
  5. Push the changes to the Oracle Developer Cloud Service Git repository. You'll be asked for your password.

    $ git push origin master
    Password for 'https://user-name@service-url':
    Counting objects: 15, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (8/8), done.
    Writing objects: 100% (8/8), 694 bytes | 0 bytes/s, done.
    Total 8 (delta 3), reused 0 (delta 0)
    remote: Resolving deltas: 100% (3/3)
    remote: Updating references: 100% (1/1)
    To https://user-name@service-url/org-name/s/org-name_my-web-application/scm/employee-app.git
       0bf504b..8db98d6  master -> master
  6. In the Oracle Developer Cloud Service console, click the Code tab and verify that the change was pushed.

    Code page with update displayed
    Description of the image
  7. Click Build and select the employees-app-build job.

    Jobs Overview page with job selected
    Description of the image
  8. Click Build Now, and then wait for the build to complete.

    Build Now button
    Description of the image

    Two builds now appear in the Build History table.

    Build History table and Build Trend graph
    Description of the image
  9. Click the Deploy tab, then click the Gear icon, and then click Redeploy.

    Redeploy menu selection
    Description of the image
  10. In the Redeploy employees-app dialog box, select 2 (Success) from the Build drop-down list, then click Deploy.

    Redeploy dialog box
    Description of the image

    The notation "Deployment update in progress" is displayed in the deployment configuration while the deployment takes place. Eventually, you'll see an entry for the new deployment in the deployment history.

    Deployment history display
    Description of the image
  11. Click the employees-app link again to open the application.

    Now you can see the new title.

    Updated Employees application home page
    Description of the image
  12. Right-click the gear icon and select Stop to stop the application.

    Stop menu selection
    Description of the image

When you've finished, delete the deployment configuration, then delete the project.

Want to Learn More?