Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 

Introduction

Last week on DKOM São Leopoldo, I live-coded an example of a simple application in Clojure and deployed it to SAP HCP. In this article you will how to deploy the Clojure application I created on the presentation. You will not find implementation details in this article at this moment.

Installation and setup of the environment

In order to follow the example, it is required to install Clojure. The easiest way to achieve this is by installing leiningen. Follow the steps in the homepage of leininen for your specific environment.

The application

The application code can be found here. It is a simple URL shortener which contains only two use cases: to register an URL to be shortened, and to redirect to the long URL in the case the URL is already registered.

In order to be able to use the code directly and deploy to HCP, clone it from GitHub, get into the folder and run the command below:

$ lein ring server

Deployment

In order to deploy to HCP, we need to create a WAR file which contains all the dependencies to execute the code. Afterwards, it is possible to upload it to HCP.

In order to create the WAR file, we can run the command:

$ lein ring uberwar

In order to create the 'Java Application', go to your HCP Trial Cockpit, and Click on 'Java Applications' on the side bar, then click the button 'Deploy Application'.

In the popup window, select the WAR file created in the step below by clicking the "Browse" and selecting the file. Afterwards, give the application a name and for "Runtime name" select "Java Web".

It is possible afterwards to start the application. The location of the link you should access can be see in the images below. Just don't forget to add the "/" at the end of the address.

Conclusion

It is possible to use HCP with other JVM hosted applications such as Clojure which allows to run the code in the SAP Cloud using a modern, dynamic and functional programming language.