IBM BlueMix CloudFoundry set up or how to get TomEE on BlueMix

IBM BlueMix is the new IBM cloud platform. It supports Docker, cloud foundry and openstack. As a default EE container, they offer WebSphere Liberty Profile. But your preferred EE server is not that complicated thanks to the extensibility of the platform.

This post shows how to deploy your TomEE application on BlueMix pretty quickly.

Create an account

First of all, create a BlueMic account if you already don’t have one, and log in. You should see something like 1_new-space. You can create a new “space” if you want but by default you should have the “dev” space. Spaces are mainly containers for “applications” (from VM to API).

Set up cloud foundry client

If you haven’t got it yet, install cloud foundry client (cf). You can download it here. Then set it up to be linked to your BlueMix account, type cf login  and fill the asked inputs:

$ cf login

API endpoint>


Authenticating ...

Target org

Target space dev

API endpoint: (Version API: 2.23.0)
Space:          dev

Prepare the application

We will use cloud foundry java buildback (kind of environment configuration). This means that we have to be able to run a main(String[]) which will deploy the web application on port provided in $PORT environment variable. For that, we will use TomEE Embedded and a modified version of the shade explained on Tomitribe blog: 50 shades of TomEE. Our main (“Run” class) will be trivial and will simply setup the HTTP port as shown below:

public class Run {
  public static void main(final String[] args) throws Exception {
    final Configuration configuration = new Configuration().http(Integer.parseInt(System.getenv("PORT")));
    try (final Container c = new Container(configuration).deployClasspathAsWebApp()) {
        new CountDownLatch(1).await();
    } catch (final InterruptedException e) {

Side note: to get a ready-to-deploy application, you can reuse tomee JAX-RS starter. For my part, I renamed the artifactId to “simple-jaxrs”. Here is what a pom for such a project can look like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""

  <!-- Change: groupId, artifactId, version -->


                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                <filter> <!-- we don't want JSF to be activated -->



Deploying the application (or updating it) is done through a simple command:

cf push simplejaxrs -p target/simple-jaxrs-1.0-SNAPSHOT.jar -b java-buildpack

Here, it is important to specify the deployed executable jar (-p) and the buildpack to use (-b). This push command will deploy the applicaion. The logs are like:

Création de l'application simplejaxrs de l'org / espace dev en tant que

Création de la route

Liaison de à simplejaxrs...

L'ajout simplejaxrs ...
Téléchargement de fichiers d'applications à partir de: target/simple-jaxrs-1.0-SNAPSHOT.jar
Téléchargement de 86.7M, 25080 fichiers
Done uploading

Arrêt de l'application simplejaxrs dans l'org / espace dev en tant que

À partir de l'application simplejaxrs dans l'org / espace dev en tant que
-----> Downloaded app package (40M)
-----> Downloaded app buildpack cache (44M)
Cloning into '/tmp/buildpacks/java-buildpack'...
-----> Java Buildpack Version: b87847f |
-----> Downloading Open Jdk JRE 1.8.0_45 from (found in cache)
       Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.4s)
-----> Downloading Open JDK Like Memory Calculator 1.1.1_RELEASE from (found
in cache)
       Memory Settings: -XX:MaxMetaspaceSize=104857K -XX:MetaspaceSize=104857K -Xss1M -Xmx768M -Xms768M
-----> Uploading droplet (71M)

0 de 1 d'instances en cours, 1 démarrage
0 de 1 d'instances en cours, 1 démarrage
0 de 1 d'instances en cours, 1 démarrage
1 de 1 d'instances en cours
Application démarrée


Application simplejaxrs a été démarrée avec la commande `CALCULATED_MEMORY=$($PWD/.java-buildpack/open_jdk_jre/bin/java-buildpack-memory-calculator-1.1.1_RELEASE
-memorySizes=metaspace:64m.. -memoryWeights=heap:75,metaspace:10,stack:5,native:10 -totMemory=$MEMORY_LIMIT) && $PWD/.java-buildpack/open_jdk_jre/bin/java -cp $PWD/.$TMPDIR -XX:OnOutOfMemoryError=$PWD/.java-buildpack/open_jdk_jre/bin/ $CALCULATED_MEMORY org.superbiz.Run`

Santé et état de l'application simplejaxrs de l'org / espace dev en tant que

État: started
instances: 1/1
utilisation: 1G x 1 instances
dernier téléchargement: Wed Jun 17 17:07:56 UTC 2015
stack: lucid64

     state        depuis                   cpu     mémoire        disque          details
#0   fonctionne   2015-06-17 07:10:04 PM   58.7%   336.3M de 1G   270.9M sur 1G

Note: for an update, the three first blocks are replaced by:

Mise à jour de l'application simplejaxrs dans l'org / espace dev comme

Then you can simply access the application on the provided url:


If you deployed the tomee JAX-RS starter application, have a look at for instance. And here it is! For next application updates, build the project locally and re-execute push command. Also note that you can use cloudfoundry maven plugin to automate it and integrate it with your build/deployment infrastructure. If you go back to the BlueMix GUI you’ll see your application with few statistics, access to logs, environment…



8 thoughts on “IBM BlueMix CloudFoundry set up or how to get TomEE on BlueMix

    1. rmannibucau Post author

      I don’t have much time but it is really just a matter of creating an account and running the 2 commands I shared. If you are stucked somewhere don’t hesitate to post the issue you encounter.

  1. Rohit Kelapure


    The correct way to do this is to create a TomEE buildpack that is an upstream fork of the Java Buildpack The java-buildpack stages apps within the Tomcat container. It would be trivial to make a TomEE buildpack – basically replacing the tomcat binary with TomEE and changing the release command of the buildpack. If you want to discuss more you can find me at @rkela or

    Creating a buildpack will allow customer apps to run in the cloud(Cloud Foundry and Bluemix) without any modifications. Each app will NOT have to include the TomEE runtime within the app.


    1. rmannibucau Post author

      There are TomEE buildpack already all around the net but then you depend on the creator and it is not the same deployment/dev lifecycle.

      I think both make sense but wanted to show you dont have to follow the whole old EE lifecycle to develop an app in the cloud today.

      Thanks for the comment BTW, really forgot to mention this option.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s