Running Railo on Amazon's Elastic Beanstalk

January 25, 2011 · By Mark Drew · 8 Comments

With the release of Amazon's AWS Elastic Beanstalk service, it has never been easier to run Railo in the cloud. Amazon BeanStalk is a way to deploy Java Applications (which is what Railo is essentially) as war files into existing Tomcat containers that AWS manages for you. It also allows for easy scaling and balancing.

This tutorial will take you through setting up an environment that you can develop and deploy a sample application up to Beanstalk, rather than just a single WAR file.

By the way if you want to just get Railo running you can do that by reading getting started documentation hosted here: http://docs.amazonwebservices.com/elasticbeanstalk/latest/gsg/ and using the Railo WAR to upload.

1) Required software

Before we get running, let's go and get all the things we need to build both a local environment and deploy to Beanstalk:

  1. Eclipse IDE for Java EE Developers http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/heliossr1
  2. Apache Tomcat 6.0 (this is what is deployed in Beanstalk so might as well have a local copy) http://tomcat.apache.org/download-60.cgi
  3. AWS Toolkit for Eclipse use the following Eclipse update site: http://aws.amazon.com/eclipse/
  4. CFEclipse (if you are going to be editing CFML you might as well get it)use the following update site: http://www.cfeclipse.org/update/
  5. Railo Server as a WAR: just download the all OS WAR version from : http://www.getrailo.org/index.cfm/download/

2) Sign up and Credentials

So that you can use Beanstalk you should obviously sign up for it! Head over to http://aws.amazon.com/elasticbeanstalk/ and then you can sign up for an account, once you have been accepted (takes a few seconds really) you should also get your Account info. Sometimes this is misleading so head to your AWS Account page at http://aws.amazon.com/account/: and you will be able to click on "Security Credentials" and make a note of your Access Key ID and Secret Access Key.

3) Install the plugins for Eclipse

Once you get Eclipse running, you need to install the plugins, if you have not used Eclipse before it's very simple, click on Help -> Install New Software... and add http://aws.amazon.com/eclipse/ to "Work With" field

Select the whole of the AWS Tookkit for Eclipse, and accept the licnese and follow the prompts until it restarts Eclipse. Follow the same procedure to install CFEclipse.

4) Creating the project

Now that we have Eclipse all ready to go with the plugins, we can create a new project in Eclipse and select the AWS ->AWA Java WEB Project.

When you click next, you will need to give your project a name, so for example "railo_demo" and enter your AWS Access Key ID and Secret Access Key, we can just select a Basic Java Web Application, since we are going to replace a lot of it with our own Railo WAR.

Click Finish.

4) Running the application locally

Now that we have the basic project setup, we need to run it locally. Right click on the project and select Run As -> Run On Server

Hit Next >

Now we define the local server that we are going to be using, select Tomcat V6.0 and using the Browse... button point it to your local Tomcat installation directory

Press Finish and the local server should be created. and started, you should get a window in Eclipse like the one below:

Now that we have this running fine, click on the Servers tab (shown above) and stop the server. Double click on the server and you will get a Server configuration screen.

Under "Server Options" tick the checkbox that says "Server modules without publishing" and save the page.

Now we are going to deploy Railo into our WebContent folder. To do this you first need to rename the "railo-3.2.1.000.war" file to "railo-3.2.1.000.zip" file and unzip it, this should give you a folder called "railo-3.2.1.000" open the folder and select all the contents (including the WEB-INF) folder and copy them to the WebContent folder in your project.

Start the server again and if is all working you should get the railo startup page!

You can now do any configuration you need to such as adding a server and web password (under http://localhost:8080/railo_demo/railo-context/admin/web.cfm ). Once you have done this, make sure (and click refresh on the WEB-INF folder) that under WebContent/WEB-INF/railo/ you have a railo-web.xml file This is the Railo settings file that saves the passwords and it's important that it's deployed with the project, so that DSN's and other settings can be deployed with your project. (thanks to Doug Hughes for spotting this)

 

5) Deploy to BeanStalk

Now that we have Railo running locally, we can deploy it to BeanStalk. Right click on your railo_demo project and select "Run As" -> Run on Server:

Select to "Manually define a new server" and select the "AWS Elastic Beanstalk for Tomcat 6" from under the Amazon Web Services Folder.

Click Next > and then select to Create a new application named "railodeploy" and give the name of your new Environment as "railodemo" make sure you have no spaces or strange characters as they are not allowed by Beanstalk and you will only find out a while later. Once you have done this click "Finish"

After a while it will set up the environment and ask you for the Version Label for this deployment, leave it as is and click "OK"

The process of deploying can take some time so you will see a long progress bar that will take a few minutes as it uploads your application to Amazon S3.

Once the process is complete, you can double click on the server marked "railodeploy at AWS Elastic Beanstalk" and you will get a summary page with the URL of your deployment. Click on that and you should get the railo startup page!

That's it. Have fun deploying Railo to the Elastic Beanstalk!

Tags: Amazon Services · Configuration · Railo 3.2 · Tips

8 responses so far ↓

  • 1 Hendrik Kramer // Jan 25, 2011 at 7:10 PM

    Thanks for this blog post! We currently testing to deploy a new webapplication (that still needs to be developed) with Railo in the cloud. And managed Tomcat containers with an easy deployment sounds great. I'll recommend our customers to test this scenarion first.

    Then I only need to add MongoDB as the database layer.
  • 2 Bertrand Pignet // Jan 28, 2011 at 10:22 PM

    Thanks very much for this tutorial.
    I've completed the wall thing very fast. But now I've a probleme to commit the local version online. I searched tutorials but didn't find.

    Any Idea ?

    Thank you
  • 3 Ian Reis // Feb 4, 2011 at 4:48 PM

    Great write up it really helped me out. One problem though. When I add a sample coldbox application it runs fine on my local tomcat but when i try to push to EBS it doesnt start up. The server health is set to red
  • 4 Andrew // Mar 18, 2011 at 7:38 PM

    I just posted an entry on my blog about how to handle a couple common issues with deploying Railo apps on Amazon Elastic Beanstalk
  • 5 Tom Lenz // May 1, 2011 at 5:38 AM

    I got stuck at step 4. On my XP box, when I right click on the project, I get no Run on server as an option, only run as applet, run as run as java application and run configurations. The run configurations selection brings up a dialog box. I tried to use that to create an AWS Elastic Beanstalk config, but the Server drop down selection box is empty.
  • 6 Yuriy // Nov 9, 2011 at 12:40 AM

    Thanks for this post, it's very helpful!
  • 7 Mike Rankin // Jan 11, 2013 at 3:17 AM

    Has anybody tried this yet with Tomcaat7 now that 6 is legacy? What other features get enabled in the beanstallk? AWS is sill new to me and I'm afraid to screw with it too much.
  • 8 Mike Rankin // Jan 26, 2013 at 8:26 PM

    I created a copy of my site using Tomcat 7 and the 64bit tomcat 7 t1-micro setup on aws. It's been running for a week now and is much more stable than the legacy option. My legacy setup would spike the cpu once or twice a week and put the beanstalk into a non-recoverable state unless I went in and either rebooted or terminated the ec2 instance. Also, turning on termination protection interferes with the beanstalk's ability to recover, so you probably want to keep that off on your instances that are being managed. It's no big deal to terminate an ec2 instance once you have the beanstalk configured correctly. It will redeploy if it notices no healthy machines.

Leave a Comment

Leave this field empty: