An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Railo for Dummies Part III

March 27, 2009 · 11 Comments

Today, let's get Railo running on Tomcat! Why Tomcat? It's a robust, high-performance Java-based web server and Servlet engine and it's also very light and lean. Tomcat is also the basis of the JBoss Web Server (I'll probably cover JBoss later in this series) so all that you learn about getting things up and running on Tomcat can be carried over to JBoss when you need a full JEE server rather than "just" a Servlet engine.Download Tomcat Go to the Tomcat 6 download page and select the appropriate binary distribution of the "Core". I'm going to use the 'zip' version for Mac OS X this time (I will come back to the Windows version later when I summon up the courage to look at IIS7). If I was targeting Linux, I'd use the 'tar.gz' version but the only difference is how you extract the files. This puts a 6.3MB ZIP file in your Downloads folder which you can expand by double-clicking it. At this point, you need to fire up Terminal and start working on the command line since the startup/shutdown shell scripts and not executable directly in Finder. You'll find Terminal in Applications > Utilities - I suggest adding it to your dock since you'll be using it a lot. In Terminal, navigate to the bin folder inside the expanded Tomcat directory, e.g.,
cd Downloads/apache-tomcat-6.0.18/bin
A useful tip is that you can press 'tab' to auto-complete file paths in most Unix shells so this will probably get you there:
cd Dow[tab]apa[tab]/bin
(depending on what other files you have on your system). Now we'll make the various shell scripts executable:
chmod +x *.sh
If you use ls -l you'll see most files have permissions -rw-r--r--@ for owner-read/write and group/world readable. The shell scripts (*.sh) are now -rwxr-xr-x@ so they are executable (by owner, group and world). Now we can start Tomcat (as with the 'Express' version of Railo, we're just trying to get it up and running right now - we'll move it somewhere more appropriate in a later blog post). Starting Tomcat If you're still in the bin folder, you can start Tomcat by typing:
You should just get four lines of output saying which paths it is using. That's it, Tomcat is running! You may also notice a new application running, called org.apache.catalina.startup.Bootstrap. As with the 'Express' experiments, leave it running - it's the core Tomcat process. FWIW, I prefer using the ./ form because I can type ./st[tab] and save myself a few key strokes. If it complains it cannot find ./, you didn't get the 'chmod' command right (see above). Testing Tomcat Browse to http://localhost:8080/. You should see the Tomcat welcome page (you can't access the manager or admin consoles without doing some initial configuration - see the next post in this series). Now we need to get Railo installed and running... Download Railo Go to the download page and under "Railo Custom", pick the "war" (web archive) file: railo- I had to right-click > Download Linked File (otherwise I got a browser full of data!). In the Finder rename the file to railo.war (it'll make life easier when we test things below). Now drag railo.war and drop it into the webapps folder inside the expanded Tomcat folder. After a couple of seconds, you'll see a new railo folder appear next to the existing manager, ROOT and other folders. Tomcat has automatically deployed the web archive for you! You can now remove railo.war or at least move it somewhere else in case you need it again. Testing Railo Now browse to http://localhost:8080/railo/ and you should see the familiar Railo test page. You can now do all the usual stuff with Railo at this point - see previous posts. Stopping Tomcat/Railo Go back to your Terminal window and make sure you're still in the bin folder (the pwd command will print your current 'working' directory), then type:
After four lines of output, Tomcat will shutdown. As with startup, you can use ./sh[tab] to save yourself some key strokes. If you want to be able to just double-click the startup script from the Finder, rename it so it has no extension. The Finder will confirm you really want to remove the extension - click Remove. You can stop Tomcat by switching to the org.apache.catalina.startup.Bootstrap application (using Cmd-Tab) and quitting it like any regular application - or right-click > Quit on its dock icon. In the next part of this series, we'll get Railo running on Tomcat without needing the /railo prefix on URLs (the 'context root' in Servlet-speak) and look at ways to configure Tomcat with Apache so you can use this setup for 'real' websites.

Tags: coldfusion · osx · railo

11 responses so far ↓

  • 1 Craig Kaminsky // Mar 27, 2009 at 4:29 PM

    I've been working for the past two days (not straight through, of course!) on deploying Railo and a CFML application to the Aptana Cloud service, which uses Tomcat 6.0.6.

    Everything was easy and smooth to get installed but Tomcat (at least the Aptana Cloud version) doesn't handle SES URLs, which makes serving up pages for applications like BlogCFC and frameworks such as ColdBox.

    I've posted a couple blog entries on my experience thus far:

    I'd be curious to know if you had any issues with SES-style URLs as you go forward.
  • 2 Luis majano // Mar 27, 2009 at 10:32 PM

    Craig. Unfortunately tomcat does not support ses style urls. I have actually reported a bug to them and hopefully it will be fixed in future versions of tomcat. My sugestion is to use apache with a connector to tomcat. Then you can leverage mod rewrite
  • 3 Sean Corfield // Mar 28, 2009 at 1:27 PM

    See the Appendix to Part IV where I offer a potential workaround:
  • 4 Craig Kaminsky // Mar 28, 2009 at 1:58 PM

    @Luis: Thanks for confirming that. I've been working with the URLRewriteFilter, which does Apache-style Rewrite rules but it's a bit of a pain with Tomcat and Railo. I was able to get some (rules) in place for ColdBox that are working well. Still, not ideal

    @Sean: I'll check out the Appendix later today (need a break from URL rewriting after this morning :).

    I'm going to try and see what I can do on the Cloud with regards to getting access to Apache to connect with Tomcat.

    Thanks, again!
  • 5 Steven Parkes // Mar 29, 2009 at 9:10 AM

    I'm wondering if you got any response from the Tomcat folks about the "bug". From my reading, it looks like Tomcat is doing what the spec requires; although the .'s and *'s in url patterns look like regexs, reading the spec shows that they very much aren't. There are a small number of fixed cases that work, and that's it, at least through 2.5 of the servlet spec.

  • 6 Luis Majano // Mar 29, 2009 at 12:03 PM

    The bug is on creating servlet mappings that allow *'s after the declaration file


    I am not sure if they will fix it or not, that is up to them. I do not worry about it because usually, I use Apache in front of Tomcat and use mod_rewrite.
  • 7 Miguel Ulloa // Apr 27, 2009 at 11:42 PM


    Following what you did on part I and II, I installed ColdBox within
    I was able to run the Dashboard and created an application, but I got a 404 when I attempted to access the Railo Administrator. Is that supposed to happen? If not what do we need to do to get it to work?

  • 8 Sean Corfield // Apr 29, 2009 at 9:47 AM

    @Miguel, I suspect ColdBox assumes /railo-context/admin/ is the path to the Railo admin but if you use a WAR, the path would be /railo/railo-context/admin/ instead (so, technically, it's a bug in ColdBox not respecting the context root of the web app).
  • 9 Tristan Lee // May 24, 2010 at 8:58 PM


    Using Apache with mod_jk to connect to Tomcat, does mod_rewrite still work for you as far as SES goes? I have tried a number of things since I am using the Tomcat connector with Apache, but it seems as though once mod_rewrite handles the request and the Tomcat connector handles the CFM pages, the re-writing rules no longer work, this Tomcat saying ".com/Handler/Action" doesn't exist (same for index.cfm/Handler/Action).

    I have URLRewriteFilter loaded in the context, but I really want to use .htaccess as it's much more configurable through my control panel.
  • 10 Paul Klinkenberg // Nov 4, 2010 at 7:28 AM

    Hi Sean, it looks like the markup of this blog post has gone. Headers, code, and text are all on the same line. Headers seem to have converted into "tt" tags.
    Kind regards, Paul
  • 11 Sean Corfield // Nov 4, 2010 at 12:05 PM

    @Paul, yeah, the import to Mango Blog munged some formatting and since Mango won't allow me to update the posts (due to the - in the titles), I can't fix it right now.

    I need to update Mango to allow - in post titles, then I can fix a whole bunch of mangled old posts.

Leave a Comment

Leave this field empty