Simple Java Application Project (v4.0)

A simple project to deploy and run a Java application

Project overview

This project is designed to deploy a Java application onto a server, and then run it. The server in the project is Linux, but can be Windows or Linux. Here is a summary of what this project will achieve.

One target is configured in the project (for Linux). We can easily clone this project to add a Windows flavour.

Taking the Linux example, the target demonstrates how the project payload (HelloWorld.jar) is generic, and can be parameterised differently in each of the target s.

Parameters can be passed to the jar as command line arguments, Java Options and as environment variables.

When you run the project for each of the targets, view the logs once the deployment is finished, and see how the running jar file echoes out the different command line parameters and environment variables.

What is preconfigured and demonstrated

The project demonstrates the following configurations:
  • Target server for Linux using localhost
  • Use of the Remote agent plugin
  • A jar file, as payload
  • Environment variables per target
  • Command Line arguments per target
  • JavaExec task
  • Cloning an environment

 

How to use this project

  1. Download the project to your desktop by clicking on one of the links. The file will be saved as java-deploy-40.zip
  2. Log into your RapidDeploy instance as mvadmin.
  3. Navigate to Resources -> Projects.
  4. In the top right hand corner click on the Upload Project button.
  5. Select the zip file you downloaded in step 1.
  6. You are guided through a project import wizard. The important thing to check and change (if necessary) here is the path to the project storage directory.
  7. Once the project is imported, there are a couple of things youll need to do.
    • Firstly, navigate to Resources -> Projects and edit the project. Navigate to the  Packages  tab and click the  Create Package   button. A new package is created with a version number. This is the package you’ll deploy later, containing all the target definitions, actions and paylod ( HelloWorld.jar ) to allow the jobs to be run on all defined servers.
    • By default this job will run on the localhost. If you’re happy to run it here, skip to point 8. If you don’t want it to run here, you’ll need to clone the environment and choose a new logical host name. The other parameters can stay the same. Once you’ve created this target, an empty server definition with the logical hostname you chose will have been created. You will now need to configure this host.
    • To do this navigate to Resources -> Targets -> Servers. Select the server  with the logical name ( Display Name ) you just created. Change the hostname from localhost to the IP, DNS or resolvable hostname you actually want to connect to. You might also need to change the  Transport  tab to use either SSH or the MidVision remote agent plugin. The default here is to use the agent on the localhost to the RapidDeploy server, which if you followed a standard RapidDeploy install is installed and configured by default.
  8. Now you can run a new job to the environment of your choice.
    • Select the Play button next to the target.
    • Select the package you want to deploy from the droplist.
    • Since there is only one package, it is preselected. The latest package will always be preselected by default.
    • Click on the  Yes  button in this dialog.
    • The deployment is started and you are taken to the running jobs panel where you see the tasks executed and job log in real time.Navigate to Project -> Targets Tab.

Optional Task: Clone the target to another Server

Now we’ve deployed to a linux server, let’s clone the target to run on another server too.

  1. Firstly, navigate to Resources -> Projects and edit the project. Navigate to the Targets tab.
  2. For the one environment listed, in the Action column, select the  Clone Target button.
  3. On the Name tab, change the Server Display Name to  localhost-win   (if you ran the HelloWorld demo project, this will already exist, otherwise type it in). If you don’t have a windows server, type the name of another Linux server. Leave the other values the same and click Next.
  4. On the  Configure Directory   tab, leave the defaults. as we are creating this environment in the same project. Click  Next
  5. Click through the next tab – Here you would configure target specific Data Dictionary items to make them different for this new target. There aren’t any in this project so the tab is empty. Skip to the  Finish  tab and click  Create This Target  button.
  6. Now you’ve created the target, we will configure the localhost-win server. Click on the localhost-win server (or the new logical name you chose) in the targets list. This is a fast path to the server definition.
  7. Check the  Hostname. It should be localhost.
  8. Click the  Edit   button in the bottom right – change the Hostname to the resolvable hostname, IP adderss or DNS name of your target server.
  9. Click the Save button
  10. Now create a new package on the project, which will include this server definition.
  11. Now you have a package with two target definitions, and you can now deploy to either one, or both.

Further Reading

The following links will help you gain a deeper understanding of the tasks used in this project:

Reviews

There are no reviews yet.

Be the first to review “Java Application Deployment Blueprint”