First8 staat voor vakmanschap. Al onze collega’s zijn een groot aanhanger van Open Source en in het bijzonder het Java-platform. Wij zijn gespecialiseerd in het pragmatisch ontwikkelen van bedrijfskritische Java toepassingen waarbij integratie van systemen, hoge eisen aan beveiliging en veel transacties een belangrijke rol spelen. Op deze pagina vind je onze blogs.

Deploying your application to OpenShift

OpenShift is RedHats PaaS solution and is perfectly suited for running Java EE applications. In this article we will be deploying an existing web application to OpenShift Online. OpenShift Online automates the provisioning, management and scaling of applications.

Lets assume we have a web application we normally deploy to Tomcat and makes use of a PostgreSQL database. A pretty common setup. So, what do we need to do to get this web application deployed to OpenShift?

If you have taken a look at OpenShift, you might have seen OpenShift talks about applications as a configuration of gears, cartridges and application code. It seems obvious we need to create an application and specify the configuration  we want to use. We will be making use of the client tools for OpenShift as provided by RedHat. Information on how to install and configure them can be found here.

Application Creation

Our application will get the name demo. Since we are keeping things simple we will stick to using one small gear with Tomcat and PostgreSQL installed. Default when creating an application, OpenShift links it to a git repository and links deployment to git pushes. As we will be deploying an existing application we don’t need it. The command below will create our application and provision our gear.

If all went ok, you should get roughly the following output.

Next we need to change some settings to have more control over our deployments. We will disable automatic deployments, set the deployment type to binary and make sure we keep upto five deployments so we can restore a previous version of our application.

If all went ok, you should see roughly the following output.

Deployment Structure

Deployments to OpenShift can be performed using the client tools using the following command:

This will kick off an script on the gear that deploys the specified deployment archive. It would have been nice if you could just specify your WAR archive here, but that would be too easy. OpenShift expects a very specific deployment archive structure. The structure is as follows.

To deploy our application we need to add some files to this structure.

To package deployment as an archive, you can use the following command:

This will create the archive including everything starting inside the deployment directory.


Now we have created the binary deployment package, we are ready to deploy it to our provisioned gear. This is achieved using the following command:

If all goes well, you should see something like:

Your application should now be up and running at the following location:


This article is stitched together using information form the following publicly available sites, which you should explore further if you want to know more.