Oracle JavaOne 2017 Get Started on Oracle Cloud: Apps with Containers and DevOps Hands-On Labs (HOL)

Overview • This lab guides you through deploying and running the Blackjack Wed Service application "locally" via a Tomcat server that is spawned by NetBeans. • After successfully running the Blackjack application locally on the Oracle classroom machine, you will then place the application code on the Oracle Developer Cloud service by cloning your local Git repository to the cloud, where you then build, deploy, and run the application. • You also learn how to create an application archive of the Blackjack application that can be used to deploy the application on the cloud.

Learning Objectives

In this Hands-On Lab session, you will learn how to:

• Configure, build, deploy, and run the Blackjack application locally • Generate deployable archive files of the Blackjack application for deployment on the cloud • Create a new project in the Developer Cloud Service • Create and clone a Git repository in the Developer Cloud Service • Build the Blackjack application in the Developer Cloud Service • Deploy the Blackjack application from the Developer Cloud Service onto the Application Container Service • Test the deployed Blackjack application that is running on the Application Container Service

Prerequisites

• Ensure that you have a working Oracle Cloud account that you can access • Successfully establish a VNC connection to a VM environment that has been supplied for you Lab Environment

You will do the labs on a VM that has been provided to you.

Note: All necessary installations and configurations of software have been done in the VM. If wish to do the practices on your laptop, you will need to do the installs and configurations of the software.

The following software has been installed software on the VM:

• JDK - (JDK) is a software development environment used for developing Java applications and applets. o It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java development. • Netbeans - A software development platform written in Java. o Applications are developed from a set of modular software components called modules. Used for development in Java, PHP, C/C++, and HTML5 • GIT - Open source version control system (VCS) for tracking changes in computer files • Maven - Apache Maven is a software project management tool. o Describes how software was built, and it describes its dependencies • Notepadd++ - A text editor and source code editor. It supports tabbed editing, which allows working with multiple open files in a single window.

Lab Files

On the Desktop of the VM is the HOL lab files directory. It contains files you will use in the labs.

• Blackjack.zip • Helloworld-Example.zip • Pom.xml Understanding DevOps and Containers

Before you get started, take a few moments to familiarize yourself with DevOps and Container, and the two Oracle services, Oracle Developer Cloud Service and Oracle Application Container Service you will use in the HOL lab.

What is DevOps?

DevOps (development and operations) is an enterprise software development phrase used to mean a type of agile relationship between development and IT operations. The goal of DevOps is to change and improve the relationship by advocating better communication and collaboration between these two business units.

Oracle Developer Cloud Service integrates with popular IDEs, including , Oracle JDeveloper, and NetBeans. IDE users can develop and commit code through Git integration tools, work with tasks and defects through Mylyn integration, monitor builds, and more.

The key cloud services are Oracle Developer Cloud Service (DevOps and collaboration), Oracle Application Container Cloud (polyglot microservices), Oracle API Platform Cloud Service (API management), Oracle Container Cloud Service (Docker), Oracle Mobile Cloud Service (mobile), and Oracle Management Cloud (application performance monitoring and log analytics).

Oracle Developer Cloud Service (ODCS)

Oracle Developer Cloud Service is a software development Platform as a Service (PaaS).

As part of Oracle Cloud, Oracle Developer Cloud Service simplifies development with an automatically provisioned, scalable development platform supporting the complete development lifecycle. Within minutes, you and your team have immediate access to source repositories, issue tracking, builds, and more.

Oracle Developer Cloud Service has these key features: • Project configuration and user management • Source control repositories through Git and Maven • A defect tracking system to track tasks, bugs, and enhancements • Continuous build integration through Hudson • Document collaboration through wiki

The web interface provides project creation and management, a dashboard to display the latest activity and build status, an issue tracking interface to edit and query defects and tasks, a wiki interface to write project documentation, a Hudson view to manage builds, and a Team view to configure teams and define roles.

Oracle Developer Cloud Service also integrates into popular IDEs, including Eclipse, JDeveloper, and NetBeans. IDE users can develop and commit code through Git integration tools, work with Tasks and Defects through Mylyn integration, monitor builds, and more. Oracle Developer Cloud Service also provides an SSH access to interact with the hosted Git repositories.

Oracle Developer Cloud Service provides tight integration with Java Cloud Service. You can manually deploy application build results from Hudson to your Java Service instance, or you can configure continuous deployment. In addition, you can deploy build results to your on premise production environment.

What is Container?

Containers or virtual environments running on a containerization host run the same version of the OS. Unlike a hypervisor, which runs Virtual Machines, you need a host operating system to run containers or a containerization platform, such as LXC with Docker. LXC (Linux Containers) is an operating-system- level virtualization method for running multiple isolated Linux systems (containers) on a control host using a single Linux kernel.

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.

A Docker image contains everything that is needed to run your software: the code, a runtime (e.g. the JVM), drivers, tools, scripts, libraries, deployments, etc.

Oracle Cloud Infrastructure Container Service Classic provides an easy and quick way to create an enterprise-grade container infrastructure. It provides you the tools to compose, deploy, orchestrate, and manage Docker container-based applications on Oracle Cloud Infrastructure for Dev, Dev/Test, DevOps, and Cloud Native use cases. It consists of Oracle Container Cloud Service and Oracle Application Container Service

Container Service Classic

Oracle Container Service Classic provides an easy and quick way to create an enterprise-grade container infrastructure. It delivers comprehensive tooling to compose, deploy, orchestrate, and manage Docker container-based applications on Oracle Cloud Infrastructure for Dev, Dev/Test, DevOps, and Cloud Native use cases.

Oracle Application Container Cloud Service (OACCS)

OACCS includes Oracle Java SE Cloud Service, which lets you deploy Java applications to the Oracle Cloud, and Oracle Node Cloud Service, which lets you deploy Node.js applications to the Oracle Cloud. You can also deploy PHP applications. When you deploy your application, you specify whether it’s a Node.js, Java, or PHP application. Subscribing to Oracle Application Container Cloud Service makes all types available when you deploy. Your application runs in "https://www.docker.com/what-docker" target="_blank">Docker container.

Oracle Application Container Cloud Service has these key features: • A pre-configured environment for Java, Node.js, and PHP applications. • Java SE advanced features such as Java Flight Recorder, Java Mission Control, advanced memory management, and ongoing and timely security updates. • Open platform that supports all Java frameworks and containers such as Spring, Play, Tomcat, and Jersey. • Support for (JVM) based languages such as JRuby. You can run any language that uses the Java Virtual Machine on this service. • Enterprise-grade support from Oracle. • Web-based user interface and REST API.

Oracle Application Container Service (ACCS) provides a simple platform for hosting Java SE, Node.js, PHP and recently Python applications.

In addition, you can choose to integrate with other Oracle Cloud services. You can develop your application on your local system, or you can use Oracle Developer Cloud Service.

With Oracle Container Service Classic, you have a Container Cloud service where you are upload the Docker image with whatever you want inside, and the service will provide the infrastructure to run the Docker containers for you.

With Oracle Application Container you can upload a ZIP file containing the application, and the service will provide the runtime for you, using Docker. Think of Oracle Application Container as a layer above Oracle Container Service Classic. Understanding the environment for Building and Deploying Applications with Oracle Developer Cloud Service and Application Container Cloud Service

Note: You don’t have to do any of the following steps. The information is provided to you for you to understand how the environment was created so you can do the same on your machine.

To provide you the time you will need to build and deploy application with Oracle Cloud Services during in the HOL session, the following installation and configuration steps has been completed for you.

Please review the following to understand what you will need to do to set up your environment for building and deploying applications in the Oracle Cloud

1) Install and configure JDK, Netbeans, Git and Maven

2) Setting Proxy for Maven

Apache Maven is a software project management tool. When you use Maven, it will go the Maven site to download the modules you will use. If you are connected to a network, like on your company’s network, and a HTTP proxy server is set up to prevent connection to the internet directly, then you must set up proxy for Maven or Maven will fail to download any dependencies

As you are connected to an Oracle University environment to do your practices, you are connected to a network with a HTTP proxy server. You will need to set proxy for Maven.

For the HOL session, proxy has been set with the proxy address of the environment you are using for Maven.

Review the settings.xml file in the following two locations to see how to set proxy with the proxy address of the environment you are using for Maven. Look under the tag. • WINNT(D:)>Program Files>NetBeans8.2>java>maven>conf • WINNT(D:)>Maven>apache-maven-3.3.9>conf

3) Creating and Configure a Git Repository Git is a tool you use to manage a project, or a set of files, as they change over time. Git stores information in a data structure called a repository. A Git repository contains, among other things: sets of commit objects, and references to commit objects

The following commands were executed in Git Bash to create, and initialize a local GIT repository under the home directory of the VM a) Create a Git Repository i) Click on the Git Bash on the Desktop to launch Git Bash ii) Create a cloud directory - mkdir cloud iii) Change the directory to cloud directory - cd cloud iv) Create a Git repository - git init The cloud directory is now a Git repository. v) Execute the ls –a command to confirm the same. The output of the ls –a command must match the output in the following screenshot:

You should see that a .git directory has been created inside the cloud directory, your repository is ready.

b) Configuring a GIT Repository Before you can commit changes to GIT repository, you must configure your name and email address to identify your commits in the repository. i. Execute the following commands to configure your name: git config --global user.name “Your Name” Example: git config –global user.name “John Doe” ii. Execute the following commands to configure your email address: git config --global user.email your-email@address Example: git config –global user.email “[email protected]” iii. To confirm that the values have been set, execute the following command: git config --global –l You should see the following: Notes:

• This sets your name and email address for all GIT projects. • Don’t use --global option to set the name and email address at the project level. Test, Build and Deploy the Blackjack Web Service App

I) Deploying the Blackjack Application on a Local Server

Note: You don’t have to do any of the following steps. The information is provided to you for you to understand what has already been done on the VM used in the HOL session.

The following steps were done to deploy the Blackjack application locally to Server bundled with the project.

1) On the Desktop, right-click and create a directory and name it Cloud 2) Copy the Blackjack.zip from the HOL lab files directory into the Cloud directory 3) Right-click on the Blackjack.zip file, select 7-Zip, click Extract files, click OK and accept the location.

When you extract Blackjack.zip, you will see the Blackjack directory, and two sub-directories (Blackjack- part2 and html5-client) The source for the Blackjack application has been created for you. It is in the Scr directory in the Blackjack-part2 directory

Blackjack-part2 • Scr – Source code for Blackjack • Manifest.json – Configuration file for deploying to Oracle Application Container Cloud Service • Pom.xml – Defines plugs in for Maven html5-client • cards folder – Images of the deck of cards • lib folder • jQuery files – jQuery is a feature-rich JavaScript library so to use JavaScript on your website. • CSS files - CSS is the language for describing the presentation of the web pages • index.html – An html file (HyperText Markup Language), it defines the structure and layout of a web page. • request.json – A json file, JSON ( JavaScript Object Notation) use to store information of how you request your cards in Blackjack

4) Launch Netbeans using the NetBeans IDE icon on the desktop. 5) Open the Blackjack project, a. In Netbeans - File>Open Project b. Select from Desktop>Cloud>Blackjack> Blackjack-part2 c. Click Open Project

Note: If all source resources are not available, you might see the following on the screen

If you see the screen, click on Resolve Problems. It will open a Resolve Project Problems window, click Resolve. When Netbeans have download the Maven related files, you will see the Final Memory amount in the Output Window area, then click the Close button in the Resolve Project Problems window.

6) Right-click the backjack-part2 project and select the Clean and Build.

A CLEAN and BUILD will build your application for deployment. When you use the Clean and Build command, the IDE runs a build script that performs the following tasks: a. Deletes any previously compiled files and other build outputs. b. Recompiles the application and builds a JAR file containing the compiled files 7) Deploy the project on Tomcat Server a. Right-click the backjack-part2 project and select Run. b. Select com.example.Blackjack.rest.Application from the Available Main Classes list, and click the Select Main Class button.

c. You know your application has started and is running when you see a “Started Application in <> seconds (JVM running for 5.19)” message in the Output window.

Note: You may encounter a problem in running this project if there port conflict. This application will be deployed to Apache Tomcat Server and it requires local port 8080 to listen to the client request. Make sure you stop the any services running on local port 8080.

TCPView tool can be used to identify and terminate the process using this port number. [Download Link](https://technet.microsoft.com/en-us/sysinternals/bb897437) START HERE FOR THE JavaOne HOL (HANDS ON LAB)

As the install and configuration has been done for you, you are starting with the next step - Testing the Locally Deployed Blackjack Application”

II) Testing the Locally Deployed Blackjack Application

Before you run the gaming console of the Blackjack application that has been deployed locally to the VM of the machine you have been assigned to, let’s review what has been done on that VM.

What has been completed in VM:

1. Installed JDK, Netbeans, Git and Maven 2. Set proxy for Maven 3. Created Cloud directory on Desktop of VM 4. Created, and initialized a local GIT repository 5. Deployed the Blackjack Application on a Local Server

This is showing the Desktop on the machine provided by Oracle University. When you log in to the machine, you will not see software started like below, it just intent to show an example of the Desktop when some software (Explorer, Netbeans, and Firefox) is launched.

An HTML-5 client application interacts with the Blackjack gaming application deployed on the Tomcat Server that is installed locally when Netbeans was installed on the VM.

1) Launch Netbeans using the NetBeans IDE icon on the desktop. 2) Open the Blackjack project, a. In Netbeans - File>Open Project b. Select from Desktop>Cloud>Blackjack> Blackjack-part2 c. Click Open Project

3) Deploy the project on Tomcat Server a. Right-click the backjack-part2 project and select Run. b. Select com.example.Blackjack.rest.Application from the Available Main Classes list, and click the Select Main Class button. c. You know your application has started and is running when you see a “Started Application in <> seconds (JVM running for <>)” message in the Output window.

4) Run Blackjack application locally a. Go to Desktop>Cloud > Blackjack > html5-client directory. b. Open the index.html file with Firefox, or enter file:///D:/Users/Administrator/Desktop/Cloud/Blackjack/html5-client/index.html in the browser c. Make sure that the first field, Service, is populated with value, enter a number between 1 and 9 in the second field, and then click Connect. 5) Once you connect to the Blackjack application gaming console a. Click the Debug on/off button to view the Debug console. b. You can use the Hit and Stand buttons available on the UI to play the game.

6) Close this HTML5 Client application once you are done. III) Generating Application Archive Files for the Blackjack Application

Oracle Application Container Cloud can deploy and run Java Platform, Standard Edition (Java SE), and Node.js applications. First, to deploy your application, we compress the application in a ZIP or Gzipped Tar (TGZ) archive file, which includes the required configuration information.

You will use Oracle Application Container Cloud Service later in the lab.

1) Create an application archive. i. Open the Blackjack-part2 application in NetBeans if it is not opened already. ii. Right-click the project and click Clean.

A Clean will remove what you have created before. iii. When you see “Build Success“in the output window, the Clean is completed.

iv. Open a graphical file explorer, navigate to Desktop> Cloud > Blackjack > Blackjack- part2, and make a note of the directory structure and its contents.

Note: The manifest.json file is required for all applications deployed to Oracle Application Container Cloud Service. If this file is not present in the root directory of the.zip,.tar, or.tar.gz file, deployment will fail. At a minimum, this file specifies the major version of the runtime environment and the launch command.

Note also, in the manifest.json file, it shows a java -jar Blackjack-part2-1.0.jar file will be created as a result of a Build.

Content of the manifest.json file: { "runtime": { "majorVersion": "8" }, "command": "java -jar Blackjack-part2-1.0.jar", "release": { "version": "1.0", "build": "1", "commit": "1A2B345" }, "notes": "Blackjack Web Service" } ``` v. Switch to NetBeans, right-click the Blackjack-part2 project, and click Build.

A Build will compile only the source files that need to be compiled, and link them together to form a new binary.

vi. When you see “Build Success“in the output window, the Build is completed

vii. Switch to the file explorer, Desktop>Cloud > Blackjack > Blackjack-part2 directory and notice that a new directory named target is created.

Examine the target directory. You will notice that.zip and.tar.gz distribution files have been generated.

These are application archive files you will use to deploy to OACCS. IV) Logging into Oracle Cloud account, and Setting Replication Policy

In the upcoming lab, you will require storage in the Cloud when you create an empty project with a repository to push your application to Developer Cloud Service. To protect the items you store in Oracle Cloud, you must define, the Replication Policy.

You will choose a replication policy (if it is not already done by the Identity Domain Administrator) to define your primary data center and also specifies whether your data should be replicated to a geographically distant (secondary) data center.

The Cloud Account you will use during the HOL session already has the Replication Policy set. The following is showing you what you might need to do for your Cloud account.

So, the HOL session, you DO NOT need to set Replication Policy. Just log into the Cloud Account and continue with the lab.

Have available, the cloud login credentials and link you received from Oracle.

1) Login to your Oracle Cloud Account a. Go to the URL: https://cloud.oracle.com/ b. Click Sign In

IMPORTANT: Use the credentials provided by your instructor or from the information from your Trial confirmation email. Select the correct data center, leave “Traditional Cloud Account” selected, and click on My Services. NOTE: The Identity Domain, User Name and Password values will be given to you by the instructor or within your Trial confirmation email.

c. Enter your Identity Domain and click Go.

d. Enter your User Name and Password and click Sign In

e. You will see a Dashboard displaying the various cloud services available to this account. 2) Customize Display of Services on Dashboard a. If your Storage cloud service is not visible, click on the Customize Dashboard. b. To add services to the dashboard, click, Show.

For the labs of this HOL, you will want to ensure that you are showing at least the Application Container, Developer and IaaS Storage cloud services.

If you do not want to see a specific service on the Dashboard, click Hide

3) Set Storage Replication Policy

As you do not need to set Replication Policy in the HOL session, proceed to - (V) - Creating a New Project in Developer Cloud Service (DevCS)

Depending on the state of your Cloud Account, you may need to set the replication policy, if it has not been previously set.

Go to the Storage Cloud Service to check on the status of the Replication Policy. a. Click on the Storage Cloud Service b. Click on the Open Service Console icon at the top of the screen. c. If the follow dialog is displayed, “Replication Policy Not Set”, then you will need to set the Replication Policy. Care must be taking when setting your replication policy, because it cannot be changed. i. From the Actions menu, select Set Replication Policy ii. The Set Replication Policy dialog box appears. It displays the available data centers and replication policies for your Oracle Storage Cloud Service instance. iii. Select the data centers locations iv. After selecting a replication policy, click Set. v. The Confirm Replication Policy Selection dialog box appears vi. Take the default and click on the Set Policy button. Your replication policy is now set

V) Creating a New Project in Developer Cloud Service (DevCS)

Create an empty Project in Developer Cloud Service

1) On the Developer Cloud Service on the Dashboard, click on the menu (gray horizontal lines). Click the Open Service Console button.

Note: developer34358, the name of the Service instance in DevCS, it will be different for every user.

2) On the Developer Cloud Service page, click New Project 3) Enter the Project Name and Description as shown in the following screenshot and click Next

4) Click the Empty Project template and Next.

5) Select MARKDOWN from the Wiki Markup drop-down list and click Finish.

Markdown is a plain-text formatting, and a software tool, written in Perl, that converts the plain text formatting to HTML 6) Provisioning BlackjackProj project may take several minutes. When provisioning is completed, there will be a check next to all the modules.

7) The home screen of the BlackjackProj will be displayed. VI) Creating a GIT Repository in Developer Cloud Service

Oracle Developer Cloud Service uses GIT source control management to save and manage your application source code files.

Create an empty GIT repository in Developer Cloud Service.

1) On the home screen of the BlackjackProj, click the New Repository button in the REPOSITORIES section.

2) In the New Repository window, enter the repository name and a description as shown in the following screenshot and click Create. 3) It may take a few minutes to create a repository.

You will use https to connect your local GIT repository on your laptop to the GIT repository in Developer Cloud Service

4) To get the URL to access the GIT Repository in Developer Cloud Service, click the HTTP tab in the Blackjack-Part2Repo home page.

5) When you click on the HTTP tab, it will then display the HHTP. Click on the icon on the far right to copy the URL to Clipboard.

Here is an example of what will be in Clipboard. https://susan.jang%[email protected]/developer34358- ouopc083/s/developer34358-ouopc083_Blackjackproj_4583/scm/BlackjackProjRepo.git VII) Cloning a GIT Repository

Clone the BlackjackProj project to a GIT repository on Developer Cloud Service

Your goal is to clone the BlackjackProj project on your local machine to the GIT repository on Developer Cloud Service. But first, you need to clone the empty GIT repository from Developer Cloud Service to the local machine, the VM

1) Launch Git Bash from the icon on the Desktop.

Note: Git needs to connect to the internet to get to Developer Cloud Service. If you are connecting to internet on a proxy server, you need to provide Git the proxy address of the proxy server. HTTP Proxy is basically a web address you type in to your company’s proxy server so you can access the internet.

2) Set the https proxy in Git – “export https_proxy=https://ges-proxy.us.oracle.com:80/”

3) In Git, go to the cloud directory – cd cloud 4) Create a new directory for the Blackjack repository – mkdir Blackjack 5) Change to the Blackjack directory - cd Blackjack 6) Confirm you are in the Blackjack directory – cloud/Blackjack - pwd

You should see - /d/Users/Administrator/cloud/Blackjack 7) Get the http url from the previous lab - Creating a GIT Repository in Developer Cloud Service, step #5 8) Clone the DevCS repository to your local git repository – Execute `git clone

Example: git clone https://susan.jang%[email protected]/developer34358- ouopc083/s/developer34358-ouopc083_Blackjackproj_4583/scm/BlackjackProjRepo.git

Note: You will be prompted for your Cloud account password. If you are not prompted for user name and password and the command fails with a 403 error, then provide the password explicitly in the GIT repository URL.

9) Notice that there is a new directory named BlackjackProjRepo created inside cloud/Blackjack directory.

10) Change to the BlackjackProjRepo directory - cd BlackjackProjRepo In the BlackjackProjRepo directory, take the files in the Blackjack-part2 directory (Scr – Source code for Blackjack, Manifest.json – Configuration file for deploying to OACCS, and Pom.xml – plugs in for Maven) and copy it into the local git repository. Recall that this directory got created when you extracted Blackjack.zip

11) Copy and paste the Blackjack-part2 project directory from cloud/Blackjack directory to BlackjackProjRepo directory

cp -r /d/Users/Administrator/Desktop/Cloud/Blackjack/Blackjack-part2 . (Don’t forget the period at the end).

12) Note the contents in directory Blackjack-Part2Repo

13) Add the source files to GIT from project root directory - git add. 14) Commit the changes of the additional source files to the repository - git commit –m “Committing changes to BlackjackProjRepo repository”

15) Push the files to the repository on Developer Cloud Service - git push origin master Wait until all the files are pushed to the repository.

16) Switch to Developer Cloud Service to verify the files pushed to the repository.

17) In the BlackjackProj home page, click on BlackjackProjRepo.git 18) Notice that Blackjackproj project directory has been pushed to the repository on Developer Cloud Service. Click on it and see its contents.

The contents of your local server are now in the git repository in Developer Cloud Service. VIII) Building a Project on Developer Cloud Service

Build the BlackjackProj project in Developer Cloud Service.

1) In the left navigation pane, click on Build and then New Job. (To bring up the left panel, click on the 3 horizontal gray lines next to Oracle Developer Cloud Services

2) In the New Job window, enter BlackjackProjBuildJob in the job name field, and click Save. 3) On the Configure Job page a. In the Main tab, enter the following values i. Edit the job name (BlackjackProjBuildJob). ii. Enter a description (Job for Blackjack Proj Build) iii. Set the JDK to JDK 8. b. Click the Source Control tab i. Select Git as your repository. ii. For Repositories, in the drop down, select BlackjackProjRepo.git

c. Click the Triggers tab i. Check Based on SCM polling schedule

Note: This setting will enable auto-deploy feature of DevCS. After the application is modified, if changes are committed to GIT repository on DevCS, it will automatically pick up the updated code and deploy it.

d. Click the Build Steps tab. i. Click Add Build Step and select Invoke Maven 3. ii. Set the Goals to: clean package. iii. Set the POM File location to: Blackjack-part2/pom.xml e. Click the Post Build tab. i. Check Archive the artifacts. ii. Set Files To Archive to: Blackjack-part2/target/Blackjack-part2-1.0.jar, Blackjack-part2/target/Blackjack-part2-1.0-dist.zip iii. Set Compression Type to NONE. iv. Click Save

7) Click Build Now to start the job to build the application in the Cloud. If the build was successful, you'll see two files: Blackjack-part2/target/Blackjack-part2-1.0.jar and Blackjack-part2/target/Blackjack-part2-1.0-dist.zip in the Artifacts of Last Successful Build section.

You can download the file, if you ever need them, by clicking the file name.

If the build fails, then go back to check the build job configuration, or click Git Logs to see more information about the error.

Great work!

You took the application, the Blackjack game console, and deployed on the local server You then took what you deployed locally, and now build it into the cloud with Oracle Developer Cloud Service.

Next you will take what you build in the Cloud with Developer Cloud Service (DevCS) and deploy the Blackjack application to Oracle Application Container Cloud Service (OACCS) IX) Deploying a Project to OACCS from DevCS

Deploy BlackjackProj to Application Container Cloud Service from Developer Cloud Service.

1) On the BlackjackProj, home page, in the left navigation pane, click on Deploy and then New Configuration

2) In the New Deployment Configuration page, enter the Configuration Name and Application Name

3) In the Deployment Target field, click New and select Application Container Cloud 4) In the Deploy to Application Container Cloud window a. Enter (Data center, Identity Domain, Username, Password) with the credentials you received. b. Click Test connection c. When you see the Successful message, click Use Connection d. ACCS Properties i. Runtime: Java ii. Subscription: Monthly iii. Type: Automatic (Select Deploy stable build only) iv. Job: BlackjackProjBuildJob v. Artifact: Blackjack-part2/target/Blackjack-part2-1.0-dist.zip vi. Click Save

5) Click the gear icon and then select Start to deploy the application to Oracle Application Container Cloud Service.

6) After the successful deployment, right-click on BlackjackProj project name and copy the URL X) Testing the Blackjack Application Deployed to OACCS from DevCS

An HTML-5 client application has been developed and supplied with the Blackjack application to test its functionality once deployed.

Use the following instructions to test the Blackjack application.

1) Open a graphical file explorer and navigate to the Cloud > Blackjack > html5-client directory. 2) Open the index.html file with a browser. (file:///D:/Users/Administrator/Desktop/Cloud/Blackjack/html5-client/index.html) a. Make sure that the first field, Service, is populated with the URL you copied in step 6 of the previous exercise, (https://Blackjackdev2oaccs-ouopc083.apaas.em2.oraclecloud.com/ b. Enter a number between 1 and 9 in the second field, and then click Connect.

3) Once you connect to the gaming console, click the Debug on/off button to view the Debug console.

You can use the Hit and Stand buttons available on the UI to play the game like before.

Congratulations! You have deployed your application to the Oracle Cloud. Now you can access your Blackjack gaming console from anywhere you have internet access!

You can continue with the Hands-On Lab session and deploy the Blackjack application directly on the Application Cloud Service. Deploy the Blackjack WebService App Directly to Oracle Application Container Cloud

Overview This lab guides you through deploying the Blackjack application archive that you created in the previous lab to the Oracle Application Container Service on the cloud.

Learning Objectives

In this Hands-On Lab, you will learn how to:

• Deploy the application to the Application Container Service. • Obtain the cloud service URL that points to where your application is deployed. • Run the application you deployed with Oracle Application Container Service on the cloud

Prerequisites

Completion of the following labs: • Preparing the environment for Building and Deploying Applications • Test, Build and Deploy the Blackjack Web Service App

I) Logging into Oracle Cloud account

You will need your Oracle Cloud account credentials for this lab.

1) Follow the same instructions you use in the previous lab to log into your Oracle account.

II) Direct Deployment of Blackjack Application to Oracle Application Container Cloud Service (OACCS)

You will deploy an application archive to OACCS directly. You will use the same sample application, the Blackjack application, for this deployment. Oracle Application Container Cloud Service can deploy and run Java Platform, Standard Edition (Java SE), and Node.js applications. Deploy the Blackjack application to OACCS directly.

1) On Dashboard page, go to Application Container, click on the menu button, and click the Open Service Console button.

2) Click the Create Application button; this opens the Create Application window. Click the Java SE icon. 3) In the Create Application dialog box: a. Enter Blackjack-OACCS for the application name b. Select Monthly for the subscription type. c. For the Application Archive field, select Upload Archive. d. Click Browse e. Select the Blackjack-part2-1.0-dist.zip file from the target directory

f. Enter “Deploying Blackjack Application to ACCS directly” in the Notes field. g. The Create Application dialog box now shows the selected file. Under Instance, review the number of instances and the memory size. h. Click Create to deploy your application to Oracle Application Container Cloud.

4) A status message appears indicating that it is Processing Archive.

5) It will take several minutes to deploy the application. The deployment status can be viewed under the In-Progress Activity section. 6) Once the application has been deployed successfully. You will not see the In Progress Activity section Copy the application URL and paste it in a notepad. We will need this URL for testing purposes. III) Testing the Blackjack Application Deployed on OACCS

An HTML-5 client application has been developed and supplied with the Blackjack application to test its functionality once deployed.

1) Open a graphical file explorer and navigate to the Cloud >Blackjack > html5-client directory. 2) Open the index.html file with a browser. 3) Make sure that the first field, Service is populated with the URL you copied in the previous exercise, < https://Blackjack-oaccs-ouopc083.apaas.em2.oraclecloud.com/> Enter a number between 1 and 9 in the second field, and then, click Connect.

4) Once you connect to the gaming console, click the Debug on/off button to view the Debug console.

You can use the Hit and Stand buttons available on the UI to play the game. This HTML5 Client application interacts with the Blackjack gaming application deployed on OACCS in the cloud. Congratulations!

You have successfully completed deploying Blackjack application to OACCS directly using its user interface and testing.

Now that you have completed the cloud-based labs for this event, you can optionally continue with the HelloWorld application and learn how to integrate a local development environment with a cloud environment. Appendix A (optional): Test and Build Helloworld App using Oracle Developer Cloud Service

Prerequisites

• This lab can be performed prior to performing the DevCS labs if you are working on your local machine. • However, if you are at the Oracle Code Event, then this lab should be optionally performed after doing the cloud-based labs in order to maximize your time on the cloud. • If you are performing this lab on the remote VM supplied by the Oracle Code Event, then your environment has already been set up for you and you can skip this prerequisite section • If you want to set up this environment on your local machine to experiment afterwards, then follow the instructions for setting up your environment: o Windows Setup: Labs-local-windows-setup.md o Mac Setup: Labs-local-mac-setup.md

Overview • This lab guides you through the steps used to configure a local development environment to build, deploy, and test a HelloWorld application with the git, Maven, and NetBeans development tools. • Additionally, you learn how to configure a replication service in the Oracle Developer Cloud Service and build, deploy, and test a HelloWorld application on the cloud.

Learning Objectives

You will learn how to:

• Configure and clone a Git repository • Create a Maven project for a HelloWorld application • Configure a Maven pom.xml file to use plugins to configure, build, and run the HelloWorld application locally • Use Git source code control to version control your HelloWorld source files and clone them to a Git repository on the cloud • Create and configure a Developer Cloud Service project to build, deploy, and run the HelloWorld application on the cloud

I) Creating a GIT Repository

As part of this activity, you will learn to create and initialize a local GIT repository.

If you are using the environment provided by Oracle University, this has been done for you. If you wish to do this locally on your machine, please follow the instructions in the “Creating a GIT Repository” and Configuring a GIT Repository” in a previous sections in this document. II) Creating a Project with Maven Archetypes

Use the following instructions to create a Maven project using Archetypes.

1) Open a graphical file explorer, navigate to Desktop> Cloud 2) Create a Helloworld directory in Desktop> Cloud 3) Copy Helloworld-Eample.zip from >Desktop>HOL lab files to >Desktop>Cloud>Helloworld, and extract the zip file into the Helloworld directory 4) Launch Git Bash. If you closed the Git Bash window, remember you must set proxy with - export https_proxy=https://ges-proxy.us.oracle.com:80/

5) In the Git Bash window, change to the cloud directory where your Git repository is stored. - cd cloud 6) Create a Helloworld directory in >Desktop>Cloud – mkdir Helloworld 7) Change to the Helloworld directory - cd Helloworld

8) Create an empty Maven project using the maven-archetype-quickstart archetype. Enter the following command: mvn archetype:generate -DgroupId=com.example -DartifactId=Helloworld-Example - DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Note: The output of this command will look like this:

The command creates an empty Maven project named Helloworld-Example. Examine the directory structure and note that an executable class is located at com.example.App. The pom.xml file must be configured for plug-ins.

Launch Notepad++ open the pom.xml file in the HOL Lab files directory. Review the content of the file.

9) Launch Netbeans using the shortcut on the desktop.

10) Open the Helloworld-Example project created under Cloud/Helloworld directory in Netbeans. D:\Users\Administrator\Cloud\Helloworld\Helloworld-Example

11) Examine the directory structure of the project, open com.example.App executable class, and review the code. 12) . Right-click the Project Files > pom.xml file and click Open.

Note: Steps 13 through 17 defines the things you need to add to the pom.xml.

You can use the pom.xml file in the HOL Lab files directory you opened in Notepad++. Select the entire xml file, copy it, and paste it to replace all the content of the pom.xml in the source window Or You can go through each of the step and add to the current content of the pom.xml in the source window.

13) Add the following properties settings to the file before the dependencies section. This sets the Java version and encoding for the project. 1.8 UTF-8

14) After the dependencies element, add elements for build and plug-ins. 15) Add the configuration for the compiler plug-in to the plug-ins section. org.apache.maven.plugins maven-compiler-plugin 2.3.2 1.8 1.8

16) Add the exec plug-in to the pom.xml file. org.codehaus.mojo exec-maven-plugin 1.4.0 exec com.example.App

17) Add the JAR plug-in to the pom.xml file. org.apache.maven.plugins maven-jar-plugin 2.6 com.example.App 18) In the source window, right-click the pom.xml file and select Format to fix the indentation for the file.

19) Save the pom.xml file.

If you might see an issue, follow instructions on how to Resolve from the previous labs.

20) Right-click the Helloworld-Example project and click Clean and Build. When see Build Success in Output Window, then Run

21) Right-click the Helloworld-Example project and click Run.

22) Select com.example.App from the Available Main Classes list and click the Select Main Class button.

23) You should see Hello World! Output with a BUILD SUCCESS message.

24) Switch to Git Bash and change the directory to Helloworld-Example - cd Helloworld-Example

25) Execute the mvn clean compile command to clean and compile the project. When the compilation is completed you will see the target directory

26) Execute the mvn exec:java command to execute the application.command to package the application. 27) Execute the mvn package command to package the application. Note: Examine the Helloworld-Example-1.0-SNAPSHOT.jar file created inside cloud/helloworld/Helloworld-Example/target directory. 28) Execute the java -jar target/Helloworld-Example-1.0-SNAPSHOT.jar command to run the packaged application.

You executed the Helloworld application to have “Hello World!” display on your screen. III) Checking the Helloworld-Example Project into a GIT Repository Use the following instructions to store the Helloworld-Example project in the local GIT repository. 1) Change into the cloud/helloworld directory. 2) Execute the git add –n . command to see the list of files that are ready to be added to the repository. Note: Please notice that there is . at the end of the command.

3) Execute the git add . command to add the files to the repository. 4) Execute the git status command to check the files that are added.

5) Execute the git commit –m “Initial Commit for Helloworld-Example Project” to commit the files to the repository and begin version tracking. 6) Your files are now checked in for version tracking. 7) Check the status of the repository by executing the git status command.

Note: You should get a response similar to the one in the screenshot.

IV) Creating a Developer Cloud Service Project Use Developer Cloud Service to create an empty project (HelloworldProject) with a repository (HelloworldProjectRepo) to push the Helloworld-Example application that you have created in the previous activity to Developer Cloud Service. 1) Follow instructions from previous lab to log into your Oracle Cloud account, and Open Service Console in Developer Cloud Service. 2) Click New Project. 3) Enter the Project Name and Description as shown in the following screenshot and click Next.

4) Click the Empty Project template and Next. 5) Select MARKDOWN from the Wiki Markup drop-down list and click Finish.

6) Provisioning HelloworldProject may take several minutes.

Wait until all the modules are provisioned and redirected to the HelloworldProject home screen. V) Creating a GIT Repository in Developer Cloud Service Use the following instructions to create a GIT repository on Developer Cloud Service. 1) Click the New Repository button in the REPOSITORIES section.

2) In the New Repository window, enter the repository name and description as shown in the following screenshot and click Create.

3) It may take a few minutes to create a repository. Wait until the HelloworldProjectRepo repository is created and redirected to the HelloworldProjectRepo home page. 4) Click the HTTP tab in the HelloworldProjectRepo home page and copy the URL. VI) Cloning a GIT Repository Use the following instructions to clone the Helloworld-Example project to a GIT repository on Developer Cloud Service. 2) To clone a GIT repository, first change to the cloud/helloworld directory that is the root directory for your repository. 3) Execute git clone https://[email protected]/developer97367- gse00003131/s/developer97367- gse00003131_helloworldproject_16312/scm/HelloworldProjectRepo.gitgit

Notes: Enter your cloud account username and password, if you are prompted. The output of this command should be similar to the output in the above screenshot.

4) Notice that there is a new directory named HelloworldProjectRepo created inside cloud/helloworld directory. 4) Copy and paste Helloworld-Example project directory from Cloud/Helloworld directory to HelloworldProjectRepo directory Note: Content of the HelloworldProjectRepo directory should match with the contents listed below screenshot.

5) Change to the HelloworldProjectRepo directory - cd HelloworldProjectRepo 6) Add the source files to GIT from project root directory - git add . 7) Commit the changes - git commit –m “commiting changes to HelloworldProjectRepo repository” 8) Push the files to the repository on Developer Cloud Service - git push origin master 9) Switch to Developer Cloud Service to verify the files pushed to the repository 10) In the HelloworldProject home page, click on HelloworldProjectRepo.git

11) Notice that Helloworld-Example project directory has been pushed to the repository on Developer Cloud Service. 12) Click on it and verify its contents

VII) Cloning a GIT RepositoBuilding a Project on Developer Cloud Servicery Use the following instructions to build Helloworld-Example project Developer Cloud Service. 1) In the left navigation pane, click on Build and then New Job

2) In the New Job window, enter HelloworldProjectBJ the job name field and click on Save 3) In the Main tab, enter the following values: a) Edit the job name if it needs adjusting. b) Enter a description. c) Set the JDK to JDK 8.

4) Click the Source Control tab a) Select Git as your repository. b) For URL, select the URL to your Git repository. 5) Click the Build Steps tab. a) Click Add Build Step and select Invoke Maven 3. b) Set the Goals to: clean package. c) Set the POM File location to: Helloworld-Example/pom.xml 6) Click the Post Build tab. a) Select Archive the artifacts. b) Set Files To Archive to: Helloworld-Example/target/Helloworld-Example-1.0-SNAPSHOT.jar c) Set Compression Type to NONE.

7) Click Save and then click Build Now. If the build was successful, you'll see a file: Helloworld-Example/target/Helloworld-Example-1.0- SNAPSHOT.jar in the Artifacts of Last Successful Build section. You can download it by clicking the file name. If the build failed then go back to check the build job configuration or click Git Logs to see more information about the error.

With this you have successfully completed creating a local GIT repository, creating a Maven project, storing Maven project in local GIT repository, activating DevCS, creating a project and GIT repository in DevCS, cloning project to DevCS and then creating a build job for deployment.