Get Tomcat 8 RC1 Running in the Cloud For Free on OpenShift


The OpenShift application hosting platform provides best in class support for Java, making each of the most popular Java Application Servers and Servlet Containers available. At the time of this writing, the following list of Java servers are all available for use in a single step:

  • JBoss Application Server 7
  • JBoss Enterprise Application Platform 6.1.0
  • Tomcat 6 (JBoss EWS 1.0)
  • Tomcat 7 (JBoss EWS 2.0)

However, developers often need to experiment with the next generation of application servers to check out the latest features and to ensure that a smooth upgrade path can be established once a new container is officially released. In this blog post, we’ll cover each of the steps for getting the new Tomcat 8.0 (RC1) up and running on OpenShift.

Sign up for OpenShift Online

You can follow along by signing up for an OpenShift Online account. It is completely free, and Red Hat gives every user three free Gears on which to run your applications. At the time of this writing, the combined resources allocated for each user is 1.5 GB of memory and 3 GB of disk space.

Install the client tools on your machine

The OpenShift client tools are written in a very popular programming language called Ruby. With OSX 10.6 or later and most Linux distributions, Ruby is installed by default – so installing the client tools is a snap. Simply issue the following command on your terminal application:

gem install rhc

This should make the rhc command available on your system. Some systems may require you to run sudo gem install rhc instead.

To configure the OpenShift command line tools, run:

rhc setup

rhc can also be configured to communicate with your own private deployment of OpenShift.

Create a DIY application type

Now we’re all set up. We’ll need to provision a new app on OpenShift Online to house our Tomcat 8 deployment:

rhc app create mytomcat8 diy

Delete the existing start / stop scripts and stop the Ruby server

By default, the DIY application type ships with a ruby server to allow you to test that your gear was created. Since we will be installing Tomcat, we can safely stop this server and remove the existing stop / stop scripts for the DIY gear.

Enter the following commands on your local machine:

cd mytomcat8
rhc app stop mytomcat8
rm -rf .openshift/action_hooks/start
rm -rf .openshift/action_hooks/stop
touch .openshift/action_hooks/start
touch .openshift/action_hooks/stop
git add .
git commit -am "Remove scripts"
git push

Connect to your application gear via SSH

The RHC command-line tool provides a convenient way for developers to SSH into their application gear without having to know the specific userid for your app. Simply enter the following command on your terminal:

rhc app ssh mytomcat8

This will open a SSH session to the OpenShift node that contains your application gear.

Download the latest Tomcat 8 server code

After connecting to your application over ssh, change to the /tmp directory and download the RC1 Tomcat 8 distribution with the following commands:

cd /tmp

Now that we have the Tomcat 8 RC1 distribution downloaded to our OpenShift gear, we need to extract the contents of the archive:

cd /tmp
tar -zxvf apache-tomcat-8.0.0-RC1.tar.gz

This will create a directory named apache-tomcat-8.0.0-RC1.

Next, we’ll need to modify the server.xml file, specifying the ip address and ports that our server will need to bind to. Because OpenShift is a multi-tenant environment, you will need to use the internal ip address that is provided to you. In order to find this address, run the following command while connected to your OpenShift gear over ssh:

env | grep IP

OpenShift provides a lot of valuable information to your application via environment variables. Using grep can help us filter down the response to something like this:


Now we’ll need to modify our server.xml file to connect to the correct ip address and port numbers.

Old Connector:

<Connector port="8080" protocol="HTTP/1.1"
           redirectPort="8443" />

New Connector:

<Connector port="8080" protocol="HTTP/1.1"
           redirectPort="15443" />

Notice that we added an address tag to this connector.

We now need to change the following line for the Catalina Engine:

<Engine name="Catalina" defaultHost="localhost">


<Engine name="Catalina" defaultHost="">

We also need to modify the host name section to point to our OpenShift host.

<Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">


<Host name=""  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

The ports that are configured for others services will not work by default because OpenShift does not allow users to bind to any port below 15000 (other than 8080).

Because of this, we need to change the following configuration items:

<Server port="8005" shutdown="SHUTDOWN">

needs to change to:

<Server port="18005" shutdown="SHUTDOWN" address="”>

And finally, we’ll change:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


<Connector port="18009" protocol="AJP/1.3" redirectPort="8443" address="”/>

Start the Tomcat servlet container

Now we should have everything prepped and ready to fire up our new Tomcat 8 server:

cd ../bin
sh && tail -f ../logs/*

This should start Tomcat and make it accessible to the outside world via port 80. You are probably asking yourself how it’s available on port 80 when we specifically set it to use 8080. OpenShift actually has a proxy setup that will pass all traffic coming to your host via port 80 to a local server you have running on port 8080. This port is specified in the system environment variable OPENSHIFT_DIY_PORT.

Verify that your tomcat server is running by pointing your browser to your application at

If you would like to use the Tomcat management console, add a user to the tomcat-users.xml file located in the conf directory. For example, add the following role and user while removing the existing configuration:

<role rolename="manager-gui"/>
<user username="tomcat" password="openshift" roles="manager-gui"/>

What’s Next?

Java, OpenShift Online, Tomcat
Comments are closed.