Java Application for Tomcat
Objective
You have a Java application that is built with Maven and the source code is managed in a GIT repository. The goal of this tutorial is to automate the build and deployment across multiple environments. This automation will include:
Cloning the Java application code from a GIT repository
Compiling and packaging the application into a WAR file
Deploying the WAR file to Tomcat servers in multiple environments
We will walk through each of the FlexDeploy features that will be created/configured to accomplish this goal and have the application deployed in a very short amount of time.
The tutorial does not cover every feature or configuration option available in FlexDeploy.
Create Java Application For Tomcat using Blueprint
The assumption is that you have FlexDeploy installed and ready for use. When logged into the FlexDeploy, you will see the Home page. Click on the + icon on the top and click “Create Project” to create a new project.
The screen displays the list of blueprints technologies supported by the FlexDeploy. Select the blueprint from the list or you can search for the blueprint in the search filter present in the top. In our case, we will select the Java Application blueprint.
General Configuration
Scroll through this guide to fill in the blueprint properties. Select the Build and Deploy options. In our case, we select Maven as Build Option and Tomcat as Deploy Option.
Project Info
Property Name | Value for this tutorial | Description |
---|---|---|
Application Name | MobileBanking | The Application Name, artifact id for maven, JDeveloper jws name. |
Description | Creating SOA project using Blueprints | Brief description of the application. |
Source Control
Click on source repository dropdown. If you have already created a connection to your source code repository, select it from the list.
Otherwise add one by clicking on “Create new Source Repository”.
Inputs Info
Field | Required | Description |
---|---|---|
Name | Yes | A descriptive name for this SCM instance. |
Code | Yes | A technical code for the instance, without any spaces. The codes are available as variables to shell and Groovy scripts, and therefore needs to comply with their limitations. |
Source Control Type | Yes | Type of Source Control Management System. We will use Git for this tutorial. Supported Source Control Management Systems are:
|
Description | No |
|
SCM Properties | Yes | The remaining properties are specific to the selected SCM. For Git:
|
We selected the SCM type as GIT. The properties related to the GIT source control management will be displayed on the screen.
Click on Create New Credential to create a new credential password for GIT password. Enter the credential Name which is unique name to identify the password. In the secret text, enter the password and click on Save.
After saving the credential, click on Save again on the SCM instance. Do a Test Connection. The green color ticket mark will show that the connection is successful.
Enter the sparse checkout folder value, if any.
Gather Build and Deployment information
Enter values for any workflow properties which are required for the build and deploy. In the image below, no properties are required for this build. Select the target endpoint that the build and deploy should execute on. Click on “Confirm”.
Target Properties
Property Name | Values for this Tutorial | Description |
---|---|---|
Maven Run Command | package | The Maven Run command to use. |
Maven Run Arguments |
| Any additional maven run arguments to use. |
Tomcat Catalina Home | locate this value from your Tomcat server. | The CATALINA_HOME directory for the Tomcat installation. |
The Project Name will be auto updated as MobileBanking since it takes the value same as Application Name.
The Folder path is auto updated to FlexDeploy/JAVA and click on “Create”.
We can see the Folder hierarchy on the top of the project.
Summary
General Configuration
Build and Deploy Workflows
Project Properties
Select the Project Properties tab. These properties are project scoped resources and can be changed per project. The plugin operations that were added to the workflows determine the available project properties that can be configured. Update the Tomcat war and tomcat context root and save the properties.
Source Control
Branch Name
Change the branch name similar to the git repositories branch name. Click on Save.
Topology
Navigate to the Topology from the Menu. The Page with the Target Groups, Environments and Endpoints sections will be displayed. Choose a Target Group on the left. You will see a list of Environments on the right with colored circles representing each Target.
Click on Tomcat Target Group and click on the Development Environment
Color coding represents:
RED - The Endpoint is not configured
YELLOW - some of the required properties are not set,
GREEN - all required properties are set and the Endpoint is configured
Targets Properties
Clicking the environment row for DEV allows modifying the Endpoint and properties.
Build Execution
FlexDeploy is configured with everything that is required to execute a build and deploy request for the ADF application, we can execute the first build. On the Project, select the Execution tab and select the Build button.
The Build Request Form will appear and we need to:
select the environment we want to build the application in, the environments that had the Build Environment checkbox will appear in the dropdown.
select the SCM Branch that was configured on the project, this will be pre-populated if there is only one configured Branch.
submit the request, this will initiate the mavenBuild workflow.
Upon submission, the build workflow is initiated and the workflow steps are executed on the Maven target groupin the BLD environment, utilizing the LOCALHOST endpoint. Upon completion of the workflow, the execution status will be successful. More information about the workflow execution can be viewed from the Execution Id link.
With the successful execution of the build, a WAR file artifact is created, stored in the artifact repository and marked with the Project Version. Every build will generate a new Project Version. The generated WAR artifact can be viewed from the Artifacts tab.
Navigate to steps tab in order to view the workflow steps. Click on the link to view the plugin logs.
Now the application can be deployed to an environment by selecting the deploy icon as shown in the below screenshot.
The Deploy Request Form will appear and we need to:
Select the Project Version. The form will default to the latest Project Version but the dropdown will contain all previously create Project Versions.
Select the environment that the deployment will be executed in.
Select the Deploy Target Group, which will be defaulted from the Project configuration. Deployments can happen on multiple instances.
Submit the request, which will initiate the application Deploy workflow.
Upon submission, the deploy workflow is initiated and the workflow steps are executed on the TOMCAT Target Group in the DEV environment, utilizing the TEPLT01 endpoint. Upon completion of the workflow, the execution status will be successful.
The Execution Id is a link to all of the execution data related to each request, such as
the workflow execution steps
the logs for each workflow step, which can be viewed by clicking on the link under the step
the artifact, which can be downloaded
the project and environment instance property values at the time of execution
Congratulations! You have successfully completed the Java Tomcat Application tutorial.
Now that you have configured FlexDeploy for one application, it is extremely easy to add more applications. Simply use the Copy Project feature or use the blueprints feature again and a new project will be created with all of the configuration completed already. With everything copied, you can simply change the configuration as needed and be ready to build/deploy in minutes. After the first run through, the blueprint will remember some of your values, and only properties that are different on each project should need any changes.
- style