How to deploy Java application to the cloud with CloudBees PaaS

While Amazon EC2 Elastic Beanstalk are the most visible PaaS cloud provider, CloudBees Run@Cloud is a low-cost alternative. Build-in integration with continuous-build systems make it appealing to agile software development teams that wish to automate all of the build process toward contuous delivery. CloudBess provide a free micro instance for you to try and even ready to deploy “Hello word” application if you want just to check out deployment process.
They have several level of subscription with the same features as EC2 – auto scaling, number of nodes to deploy application to, choice of java servlet container or full j2ee Web profile container.
So let’s deploy simple application into the cloud. I have discovered 3 options to deploy the applications:
1. Using provided Maven plugin. Probably the simplest options if your project is based on maven.
2. CloudBees SDK. After downloading SDK you can use command shell to deploy your application from yor server or workstation.
3. Jenkins Cloudbees deploy plugin. This will execute deployment to cloudBees as a post-build task in Jenkins/Hudson.

Assuming you created account at and have your application ready. If you don’t have any to play with,
you can download one at cloudbees/holiday-competition

If you happen to use Git, then fork the project

git clone git://

Use you favorite IDE to modify the application.
I will show here how to deploy using Maven plug-in.
Make sure your pom file has following entries:

Get you account key from
Before deploying to the cloud, you can test your application locally using:

mvn bees:run

this will deploy application into embedded tomcat instance and you can test your apps locally at port 8080 or specify you own port whith -Dbees.port parameter.

Now you are ready to deploy to the cloud:
Execute command:

mvn bees:deploy 
You can use following option either in pom file or in command line:
Plugin pom.xml options (or -D for command-line):

appid (-Dbees.appid) - the ID to use when deploying the application (default uses cloudbees-web.xml value)
environment (-Dbees.environment) - cloudbees-web.xml configuration environments to use for deployed app (comma separated)
apikey (-Dbees.apikey) - CloudBees API key
secret (-Dbees.secret) - CloudBees API secret
message (-Dbees.message) - Message associated with the app deployment (will be displayed in the Web Console)

My command will looks like this:
mvn bees:deploy -Dbees.appid=myapps -Dbees.apikeys=TTRRR.... -Dbees.secret=Rthr... -Dbees.mesaage=Hello word

If you need to change configuration settings, for example for dev, stage, qa or production environment, cloudBees allow you to specify which environment variables are active for current deployment with -Dbees.environment flag.
To take advantage of it you need to have cloudbees-web.xml file. Here is a sample file. Put it into you WEB-INF directory.

<?xml version="1.0"?>
<cloudbees-web-app xmlns="">
  <environment name="prod">
    <resource name="jdbc/DATASOURCE_NAME" auth="Container" type="javax.sql.DataSource">
      <param name="username" value="DB_USER" />
      <param name="password" value="DB_PASS" />
      <param name="url" value="jdbc:cloudbees://DB_NAME" />

  <environment name="dev">
    <resource name="jdbc/DATASOURCE_NAME" auth="Container" type="javax.sql.DataSource">
      <param name="username" value="DB_USER-dev" />
      <param name="password" value="DB_PASS" />
      <param name="url" value="jdbc:cloudbees://DB_NAME-dev" />

  <environment name="local">
    <resource name="jdbc/DATASOURCE_NAME" auth="Container" type="javax.sql.DataSource">
      <param name="username" value="DB_USER-test" />
      <param name="password" value="DB_PASS" />
      <param name="url" value="jdbc:cloudbees://DB_NAME-test" />

  <!-- A common database -->
  <resource name="jdbc/DATASOURCE_NAME2" auth="Container" type="javax.sql.DataSource">
    <param name="username" value="DB2_USER" />
    <param name="password" value="DB2_PASS" />
    <param name="url" value="jdbc:cloudbees://DB_NAME2" />

After successful upload let’ navigate to application management console:

Like elastic Beanstalk and GAE, CloudBees provide versioning deployment, which allow you to see all your previous deployed builds and rollback to previous version just by clicking deploy icon on corresponding version.
Alternatively, you can upload new version using web interface and upload button.
Explore different tabs, they are self explanatory.

As you can see it is very simple to deploy application to cloudBees platform. Adding deploy step to continuous Integration build is very simple either with the same command line as we did here with maven, or by using cloudBees SDK for ant or other shell scripts or by using Jenkins/Hudson plugin.

I encourage to investigate cloudbees ecosystem services – some of them, like NewRelic monitoring or Papertrail could be useful for any application.

CloudBees gives developers ready access to cloud services and amazon infrastructure. (cloudbees build on top of EC2)
For my application, I didn’t have to start any databases, start any instances of Tomcat, or even ensure that any ports were open. The process was simple and quick. And it is free. If my application need to scale, then I can just subscribe to the better plan – no need to buy or configure additional hardware or software or load balances. Please check my deployed application and retweet the URL with hashtag #CloudBeesJava – cloudBees will donate one dollar for each retweet to charity.
I put a simple slideshow from flickr with artworks made by my wife using seashells.

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>