Deploy Java EE Apps effortlessly on AWS

At CloudCaptain we love solutions that just work. And that's why, when it comes to Java EE, we've grown very fond of Apache TomEE. Unlike traditional heavy and complex application servers, TomEE combines the swiftness of Tomcat with the benefits of standard Java EE.

Today we are happy to announce that we have added TomEE to CloudCaptain's selection of payloads that can be deployed effortlessly to VirtualBox and AWS. Just like Dropwizard, Spring Boot, Tomcat and (executable) jar files, you can now fuse TomEE applications into immutable images with a single command. These images can then be deployed unchanged to VirtualBox and AWS with zero downtime updates.

TomEE to EC2

Why TomEE?

At its core Apache TomEE stands for 3 things:

  • Be small
  • Be Java EE certified
  • Be Tomcat

TomEE does away with long and tedious deployments typically associated with Java EE. Instead you now get a Tomcat that has been tuned to be able to run Java EE applications. It's still Tomcat, but it is now also fully Java EE certified with support for EJB, CDI, JMS and more. It starts quickly and does away with .ear files. Instead you can simply use tried and true .war files and define any JNDI resources in WEB-INF/resources.xml. Java EE has never been this simple!


Before we get started ensure you have created a CloudCaptain account (it's free, just log in with your GitHub id). Make sure to associate it with your AWS account in the CloudCaptain console to deploy on EC2.

You will also need Git, Java, Maven and VirtualBox installed on your machine.

Creating a TomEE Java EE app

Start by cloning the CloudCaptain Samples repository:

> git clone

and build the TomEE sample application:

> cd tomee
tomee> mvn package

Great. You should now have a file called target/tomee-1.0.war as part of the following application:

TomEE project structure

This application uses various Java EE features including EJBs, JSPs, Servlets, JPA and JNDI.

Deploying it to AWS EC2

Now that you have built the application, let's deploy it to AWS. CloudCaptain will start by analysing it and determining its type. Doing so it will find the WEB-INF/resources.xml file. This tells it that it is a Java EE that requires TomEE instead of Tomcat.

CloudCaptain will then create a Micro-OS on-the-fly designed to do one thing and one thing only: run this version of your application.

It does that by combining your application with TomEE, a JVM, the C library, the Linux kernel and a bootloader into an tiny image. Everything is fully configured and ready to run out of the box:

TomEE War file -> CloudCaptain Image -> AWS Instance

To launch your application on AWS as well as provision and configure all necessary infrastructure, all you need to do is:

> boxfuse run target/tomee-1.0.war -env=prod

Fusing Image for tomee-1.0.war ...
Image fused in 00:08.592s (73858 K) -> axelfontaine/tomee:1.0
Creating axelfontaine/tomee ...
Pushing axelfontaine/tomee:1.0 ...
Verifying axelfontaine/tomee:1.0 ...
Waiting for AWS to create an AMI for axelfontaine/tomee:1.0 in eu-central-1 (this may take up to 50 seconds) ...
AMI created in 00:18.531s -> ami-806e6c9d
Creating Elastic IP ...
Mapping to ...
Creating security group boxsg-prod-axelfontaine/tomee:1.0 ...
Launching t2.micro instance of axelfontaine/tomee:1.0 (ami-806e6c9d) in prod (eu-central-1) ...
Instance launched in 00:38.394s -> i-dec80062
Waiting for AWS to boot Instance i-dec80062 and Payload to start at ...
Payload started in 01:00.050s ->
Remapping Elastic IP to i-dec80062 ...
Waiting 15s for AWS to complete Elastic IP Zero Downtime transition ...
Deployment completed successfully. axelfontaine/tomee:1.0 is up and running at

And there you have it, your Java EE application is now fully up and running on AWS:

TomEE app running on AWS screenshot

You can deploy new versions at any time and CloudCaptain will automatically perform blue/green zero downtime updates for you.


In this post you saw how Apache TomEE makes Java EE fast and lightweight. We took this to the next level by using CloudCaptain to deploy a Java EE application to AWS using a single command. There was no tedious configuration and the entire process took less than two minutes, including automatically provisioning all the necessary infrastructure on EC2.

Running your Java EE applications on AWS has never been this easy.

TomEE to EC2

Have fun! And if you haven't already, sign up for your CloudCaptain account now. All you need is a GitHub user and you'll be up and running in no time. The CloudCaptain free plan aligns perfectly with the AWS free tier, so you can deploy your TomEE Java EE application to EC2 completely free.

« Immutable Infrastructure: Fast & Reliable Scaling
Hello Gradle Plugin Portal! »