Mikael Sukoinen

Deploy a Java web app to Oracle Cloud

This tutorial shows you how to deploy a Java web application to Oracle Cloud. Oracle offers a 30-day free trial that includes $300 to spend on commercial services. You can find details of their free and commercial services on the Oracle website.

Note
You need a credit card to confirm your identity when signing up on Oracle Cloud.

We use the latest Vaadin Plain Java starter app in our example. The tutorial includes two options to deploy the application:

  1. Using the Oracle WebLogic console.

  2. From a GitHub repository in a CI pipeline.

Prerequisites:

  1. Create an Oracle Cloud account at https://www.oracle.com/cloud/.

  2. Verify that you have Java installed by running the java --version command in your terminal. If not, download and install the latest version on your computer.

  3. Verify that you have Git installed by running the git --version command in your terminal. If not, download and install the latest version on your computer.

  4. Verify that you have Maven (at least version 3.0) installed by running the mvn -v command in your terminal. If not, download and install the latest version on your computer.

There are many ways to deploy web apps to Oracle Cloud. This tutorial shows how to deploy the latest Vaadin starter application as a WAR (.war) file through the Oracle WebLogic Console with the Visual builder Studio as a build job from GitHub. See the Oracle Tutorial page for more deployment options.

Source code on GitHub.

Option 1: Deploy through the Oracle WebLogic Console

Download and compile the example application

  1. Download the Vaadin starter application from https://vaadin.com/start/latest.

    1. Select Plain Java as the technology stack

    2. Provide a Maven group ID and project name (or leave them at the defaults).

      Vaadin starter download page.
  2. Create a WAR archive with the mvn package command.

Setup Oracle Cloud

  1. Sign into your Oracle Cloud account at https://www.oracle.com/cloud/sign-in.html.

    Sign-up on Oracle Cloud.
  2. Create a compartment at Identity > Compartments. Provide a name and then select Create Compartment.

  3. Create an Autonomous Transaction Processing (or ATP) database instance at Database > Autonomous Transaction Processing.

  4. Select Create Autonomous Database and fill in the details:

    1. Compartment: Your root compartment.

    2. Display name: Provide a name or use the default.

    3. Database name: Provide a name or use the default.

    4. Workload type: Transaction Processing.

    5. Deployment type: Shared Infrastructure.

    6. Database version: 19c.

    7. Administrator credentials: Provide and confirm a password.

    8. Access type: Allow secure access from everywhere.

    9. License type: License included.

      Create Autonomous Transaction Processing database.
      Note
      it usually takes between 30-60 minutes for the instance to be created.
      Tip
      Select the Always Free switch to only show options that are eligible for the free account tier.
  5. Create a new policy at Identity > Policies:

  6. Select Create Policy in your root compartment.

  7. Provide a name and a description.

  8. Add the following statements to your policy one at a time:

    Note
    Substitute each instance of ‘<compartment_name>’ with the actual name of your compartment.
    Allow service PSM to inspect vcns in compartment <compartment_name>
    
    Allow service PSM to use subnets in compartment <compartment_name>
    
    Allow service PSM to use vnics in compartment <compartment_name>
    
    Allow service PSM to manage security-lists in compartment <compartment_name>
    
    Allow service PSM to inspect autonomous-database in compartment <compartment_name>
    
    Allow service PSM to inspect database-family in compartment <compartment_name>
    Create Policy.
  9. Select Create.

    Tip
    You can find more details on these steps in the Oracle tutorials page.

Create a Java service instance

  1. Go to Platform Services > Java.

  2. Select Create Instance.

  3. Fill in the details and then select Next. Example:

    1. Instance name: Provide a name.

    2. Region: Select a region. You can find more information on data regions on the Oracle documentation page.

    3. Availability Domain: Leave at the default value.

    4. License type: My organization already owns…

    5. Service Level: Oracle Java Cloud Service.

    6. Software Release: Oracle Java WebLogic Server 12c.

    7. Software Edition: Enterprise Edition.

      Create Java instance.
  4. Connect your ATP database instance and create credentials. Example configuration:

    1. SSH Public Key: Create a new key and download it.

    2. Local Administrative User Name: Provide a username.

    3. Password: Provide and confirm a password.

    4. Load Balancer: Select Oracle-Managed Load Balancer.

    5. Load Balancing Policy: Select Round Robin.

    6. Database Type: Select Oracle Autonomous Transaction Processing.

    7. Compartment Name: The name of your root compartment.

    8. Database Instance: The name of your ATP database instance.

    9. Administrator User Name: Your administrator username.

    10. Password: The password of your ATP Instance.

      Java service instance details.
  5. Confirm and then create the instance.

    Note
    it usually takes between 30-60 minutes for the instance to be created.

Configure the deployment in the WebLogic console

  1. Go to the instance you created and select Open WebLogic Server Administration Console.

    Open WebLogic Administrative console.
  2. Login with the Local Administrative User credentials you created previously.

    Warning
    If you get an authentication error, add the certificate to your browser or enable console access to continue.
  3. Select Lock & Edit.

    Lock & Edit.
  4. In Domain Structure select Deployments.

  5. Select Install.

  6. Select Upload your file(s).

  7. Upload your WAR as a deployment archive.

    Application uploaded.
  8. Select Install this deployment as an application.

  9. In Clusters select All services in the cluster under your instance name.

  10. Accept the default settings on the optional settings page and click Next. Select No, I will review the configuration later and then select Finish.

  11. Select Activate Changes, if the deployment is successful.

    Deployment successful.
    Activate changes prompt.

Start the application

  1. Open the Control tab.

    Control tab location.
  2. Select your application.

  3. Select Start > Servicing All Requests.

  4. Select Yes to confirm the deployment.

    Start request confirmation.

View the application

  1. Go to your Java service instance.

    Completed Service instance with IP.
  2. Copy the public IP address.

  3. Open your application at: https://YOUR_PUBLIC_IP/YOUR_APP_NAME. Substitute ‘YOUR_PUBLIC_IP’ with the public IP you copied and ‘YOUR_APP_NAME’ with the actual name of your application.

Option 2: Deploy as a build configuration from GitHub

This option sets up a CI pipeline from a Git repository.

Thank you Abinhav Shroff for providing the steps for the build configuration! You can follow him on Twitter @abhinavshroff and read his original blog on Medium.

Download and compile the example application

  1. Download the Vaadin starter application from https://vaadin.com/start/latest.

  2. Select Plain Java as the technology stack

  3. Provide a Maven group ID and project name (or leave them at the defaults).

  4. Create a WAR archive with the mvn package command.

  5. Push the code to a GitHub repository.

Setup Oracle Cloud

  1. Sign into your Oracle Cloud account at https://www.oracle.com/cloud/sign-in.html.

    Sign-up on Oracle Cloud.
  2. Create a compartment at Identity > Compartments. Provide a name and then select Create Compartment.

  3. Create an Autonomous Transaction Processing (or ATP) database instance at Database > Autonomous Transaction Processing.

  4. Select Create Autonomous Database and fill in the details:

    1. Compartment: Your root compartment.

    2. Display name: Provide a name or use the default.

    3. Database name: Provide a name or use the default.

    4. Workload type: Transaction Processing.

    5. Deployment type: Shared Infrastructure.

    6. Database version: 19c.

    7. Administrator credentials: Provide and confirm a password.

    8. Access type: Allow secure access from everywhere.

    9. License type: License included.

      Create Autonomous Transaction Processing database.
      Note
      it usually takes between 30-60 minutes for the instance to be created.
      Tip
      Select the Always Free switch to only show options that are eligible for the free account tier.
  5. Create a new policy at Identity > Policies:

  6. Select Create Policy in your root compartment.

  7. Provide a name and a description.

  8. Add the following statements to your policy one at a time:

    Note
    Substitute each instance of ‘<compartment_name>’ with the actual name of your compartment.
    Allow service PSM to inspect vcns in compartment <compartment_name>
    
    Allow service PSM to use subnets in compartment <compartment_name>
    
    Allow service PSM to use vnics in compartment <compartment_name>
    
    Allow service PSM to manage security-lists in compartment <compartment_name>
    
    Allow service PSM to inspect autonomous-database in compartment <compartment_name>
    
    Allow service PSM to inspect database-family in compartment <compartment_name>
    Create Policy.
  9. Select Create.

    Tip
    You can find more details on these steps in the Oracle tutorials page.

Create a Java service instance

  1. Go to Platform Services > Java.

  2. Select Create Instance.

  3. Fill in the details and then select Next. Example:

    1. Instance name: Provide a name.

    2. Region: Select a region. You can find more information on data regions on the Oracle documentation page.

    3. Availability Domain: Leave at the default value.

    4. License type: My organization already owns…

    5. Service Level: Oracle Java Cloud Service.

    6. Software Release: Oracle Java WebLogic Server 12c.

    7. Software Edition: Enterprise Edition.

      Create Java instance.
  4. Connect your ATP database instance and create credentials. Example configuration:

    1. SSH Public Key: Create a new key and download it.

    2. Local Administrative User Name: Provide a username.

    3. Password: Provide and confirm a password.

    4. Load Balancer: Select Oracle-Managed Load Balancer.

    5. Load Balancing Policy: Select Round Robin.

    6. Database Type: Select Oracle Autonomous Transaction Processing.

    7. Compartment Name: The name of your root compartment.

    8. Database Instance: The name of your ATP database instance.

    9. Administrator User Name: Your administrator username.

    10. Password: The password of your ATP Instance.

      Java service instance details.
  5. Confirm and then create the instance.

    Note
    it usually takes between 30-60 minutes for the instance to be created.

Create a Visual Builder Studio instance

  1. Go to Platform Services > Developer in the dashboard.

  2. Create a new instance, provide a name and select a region. You can find more information on data regions on the Oracle documentation page.

    Create Visual Builder Studio Instance.
  3. Select Access Service Instance once it’s created.

    Access Visual Builder from instance.
    Note
    It usually takes between 30-60 minutes for the instance to be created.
  4. Create a new project at the instance.

    Create your first project.
  5. Allow the project to be provisioned.

  6. Create an account in Organization > OCI account and connect it to the Visual Builder Studio instance. You can find more details on the Visual Builder documentation page.

  7. Go to your project, select Git and add your GitHub repository to the project.

  8. Create a build Job

  9. Go to Builds.

  10. In Main provide a name for your build and select JDK 8 as your JDK.

    Main tab.
  11. In Source Control select the Git repository that you connected earlier.

    Source control tab.
  12. In Triggers select Based on SCM polling schedule.

    Triggers tab.
  13. In Build Steps select Maven 3 (bundled) and type the clean install command in Goals to invoke Maven.

    Build steps tab.
  14. In Post Build select Archive the Artifacts, enter YOUR_APP_NAME/target/*.war and select GZIP* as the compression type. Replace YOUR_APP_NAME with the actual name of your application.

    Post build tab.
  15. Save the configuration.

You can view the build deployment in the dashboard.

Completed builds in dashboard view.

Configure a cloud service

  1. Edit the application deployment configuration in the Visual Builder Studio. Provide a name and select your build job and artifact.

    Edit configuration.
  2. Post the deployed app to the Java cloud service instance.

    All deployments in dashboard.

View the application

  1. Go to your Java service instance.

    Completed Service instance with IP.
  2. Copy the public IP address.

  3. Open your application at: https://YOUR_PUBLIC_IP/YOUR_APP_NAME. Substitute ‘YOUR_PUBLIC_IP’ with the public IP you copied and ‘YOUR_APP_NAME’ with the actual name of your application.

Vaadin is an open-source framework offering the fastest way to build web apps on Java backends
GET STARTED

Comments (0)