Buzzing the Cloud with CloudBees and Roo

Looking to try out CloudBees for your Spring application?

Here is how you can get started quickly with CloudBees Run@Cloud platform.

05-Mar-12 – Updated for Spring Roo 1.2.1

  1. Get a CloudBees Account
  2. Configure a MySql instance on CloudBees
  3. Build a Spring Roo application
    see script below
  4. Create a cloudbees-web.xml file in WEB-INF
    same directory as web.xml
  5. Add Maven CloudBees Plugin
  6. Build and deploy with Maven
    mvn clean install bees:deploy


Roo 1.2.1 Script

Here is a simple item manager application script you can use/customize to create your application.

  • NOTE: Provide MySQL credentials in the “jpa setup” line.
# FOR SPRING ROO 1.2.1 - Spring Data JPA and Service Layer

development mode --enabled true

project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees

jpa setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd

entity jpa --class ~.domain.Item --activeRecord false

field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item

repository jpa --interface ~.repository.ItemRepository --entity ~.domain.Item

service --interface ~.service.ItemService --entity ~.domain.Item

web mvc setup
web mvc all --package ~.web

logging setup --level DEBUG


Roo 1.1.5 Script

Here is a simple item manager application script you can use/customize to create your application

# FOR SPRING ROO 1.1.5

development mode --enabled true

project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees

persistence setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd

entity --class ~.domain.Item

field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item

web mvc setup
web mvc all --package ~.web

logging setup --level DEBUG


cloudbees-web.xml

<?xml version="1.0"?>
<cloudbees-web-app xmlns="http://www.cloudbees.com/xml/webapp/1">
  <appid>roobees</appid>
  <context-param>
    <param-name>application.environment</param-name>
    <param-value>prod</param-value>
  </context-param>
</cloudbees-web-app>


Maven CloudBees Plugin

Add the CloudBees repository to the pluginRepositories section.

<pluginRepositories>
  ...
  <pluginRepository>
    <id>bees-plugins-snapshots</id>
    <url>http://repository-cloudbees.forge.cloudbees.com/public-snapshot/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </pluginRepository>
  ...
</pluginRepositories>

Add the CloudBees Maven plugin to the plugins section.

<plugins>
  ...
  <plugin>
    <groupId>com.cloudbees</groupId>
    <artifactId>bees-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <configuration>
       <!-- your username/appname -->
      <appid>youruserid/roobees</appid>
      <!-- your api key -->
      <apikey>BEBEBE2CEBEBEFBE</apikey>
      <!-- your secret key -->
      <secret>GEE0GERE0E-JE0EQETEHEPET+33MEIEIEI0EEZEEIEE00+</secret>
      <message>Roo ItemManager on CloudBees by Gordon Dickens</message>
    </configuration>
  </plugin>
  ...
</plugins>


Database Properties File

Edit the /src/main/resources/META-INF/spring/database.properties file.
Set the database.url to jdbc:cloudbees://yourmysqlinstance.
Set the database.driverClassName to com.cloudbees.jdbc.Driver.

database.username=yourmysqluserid
database.password=yourmysqlpasswd

database.url=jdbc:cloudbees://yourmysqlinstancename
database.driverClassName=com.cloudbees.jdbc.Driver

Download the Demo App

The demo app is in Git https://github.com/gordonad/gordonad-roo-1.2-cloudbees for Spring Roo 1.2.


About Gordon

Technology enthusiast primarily focused on Java and Open Source projects. Spring Certified Professional and Trainer. http://twitter.com/gdickens http://linkedin.com/in/gordondickens http://github.com/gordonad
This entry was posted in Cloud, CloudBees, Roo, Spring, Spring Roo and tagged , , , . Bookmark the permalink.

7 Responses to Buzzing the Cloud with CloudBees and Roo

  1. jieryn says:

    The GitHub project link is 404.

  2. Gordon says:

    Fixed the link. Thanks for pointing that out.

  3. Pingback: Using Spring Roo on CloudBees | Cloud Computing Software Development

  4. Andrew Swan says:

    Nice to see people using the new application layering support in Roo 1.2.x! See ROO-301 and ROO-340 (and of course the reference docs) for further details.

  5. Bruce Baron says:

    In your pom you have an appkey and secret. What are they for? I couldn’t find any docs on this in the
    cloudbees site.

  6. Achille says:

    How can we make this example a facebook web app (running on cloudbees)?

Leave a Reply

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>