Railo 3.0 on JBoss AS 4.2 via Apache 2.2 with Root Context and No Proxy

So I wanted to take a good look at the Railo 3.0 CFML engine and see what all the buzz was about. I wanted to be sure I could replicate the same basic Apache virtual host configurations I've been using with my ColdFusion 8 multi-server configuration. I also decided to try to get this all working with the JBoss Application Server. This entry summarizes the battle that was eventually won...

Choosing An Application Server

After a great deal of reading comparisons and opinions regarding Resin, Tomcat and JBoss Application Server (also with/without Apache), I decided I wanted to shoot for running the Railo CFML engine on the JBoss Application Server. There was plenty of good press and lots of die hard proponents for each of these application server options, so I don't feel there's a wrong decision and recommend you decide for yourself. For me, I just liked the robustness of JBoss and the full-featured community edition (Resin, for example, only provides a lot of its full-featured options in the paid licenses).

Basic Railo Installation/Deployment (EAR/WAR)

I'll leave out a lot of the lower level details of my installations, because there are plenty of Railo installation guides out there already (and probably growing). I must, however, mention that a lot of Gary Gilbert's Railo posts were particularly useful in my learning experience.

Using the aforementioned guides I was able to get JBoss AS installed and then deployed Railo 3.0 as a WAR and then also tried the EAR deployment alternative. I was not able to deploy Railo on JBoss AS 5.0.1.GA, but all deployments worked fine for me on JBoss AS 4.2.3.GA. I've noticed other folks comment on being able to deploy Railo on JBoss 5 on Ubuntu 8.04, which is my development OS, but I was not successful. The errors I received appeared to be known JBoss 5 bugs, but who knows!

Adding Apache HTTPD to the Stack

After getting Railo 3.0 running on JBoss 4.2, I then wanted to integrate Apache 2.2, which was relatively straightforward using the mod_jk module for Apache HTTPD (again, this stuff is already well documented). At this point, however, I could either have only one Railo Web root and/or needed to use specific context paths for each Web site/context (e.g., http://localost/app1-context, http://localhost/app2-context, etc.).

Railo on JBoss via Apache, as I really wanted it to be

I then wanted to be able to run multiple Apache virtual hosts as multiple Railo web contexts on the same instance of Railo, but without needing a unique context path for each and without needing to proxy from Apache. After hours of experimentation and searching for help, I just could not find a way to make this happen.

Just as I was about to give up, I was reassured that this could be done when I read a couple installation guides that used Tomcat virtual hosts and a Railo installation using the JARs download only (not an EAR or WAR deployment): this one by James Constable and this one by Gary Gilbert.

These guys were doing exactly what I wanted to do, simply with Tomcat instead of JBoss, and since I knew JBoss AS uses Tomcat as its Web server, I knew there must be a way! I simply needed to identify the JBoss deployment directory in which to locate the Railo jars, and which web.xml and server.xml files to modify within the JBoss deployment directory structure. Here they are:

{JBOSS_HOME}/lib -- Drop the Railo jar files in here.
{JBOSS_HOME}/server/default/lib -- Drop the Railo jar files in here.

{JBOSS_HOME}/server/default/deploy/jboss-web.deployer/conf/web.xml -- Define the Railo servlet, servlet mappings and welcome files in this file.

{JBOSS_HOME}/server/default/deploy/jboss-web.deployer/server.xml -- Define Host entries for each application/virtual host in this file (to match up with Apache virtual hosts).

Next Steps

I would like to learn a bit more about JBoss AS administration and be sure my environment is configured for high performance and sensible security. I'll also want to run JBoss as a daemon that starts automatically at boot. I'm running Ubuntu 8.04 as my main development environment and I found what promises to be a fantastic article on a proper JBoss AS installation on Ubuntu!

I'm also looking for some sort of confirmation that my basic method of configuring this Railo/JBoss/Apache stack makes sense, or whether there's a preferred alternative (using WAR, EAR, proxy, etc.). I hope to get a lot of answers in the near future since Railo just recently joined forces with JBoss (read the Railo announcement here or the JBoss.org announcement here).

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Jamie Krug's Gravatar I've run into a problem with this configuration already, in an app that leverages Apache mod_rewrite quite a bit for SEO-friendly URLs...

If I use a mod_rewrite rule in an Apache vhost, something like this:
RewriteRule ^/([A-Za-z-]+)/([A-Za-z-]+)/$ /index.cfm?event=$1&param=$2 [PT,NE,QSA,L]

Then something like this:
should behave the same as:

But I instead get the following 404:
HTTP Status 404 - /friendly-event-name/friendly-param/
type Status report
message /friendly-event-name/friendly-param/
description The requested resource (/friendly-event-name/friendly-param/) is not available.

I'm sure there's some sort of work-around, but haven't found it in my initial quick search...
# Posted By Jamie Krug | 3/3/09 4:29 PM
Andy's Gravatar Jamie, thanks for your Post. I had been trying to do the same thing and ended up with the same result, a 404 from JbossWeb. I believe the solution would be to configure re-write rules within JobssWeb somehow, and there appear to be a few ways of doing this but I was unsuccessful in translating the railo rewrite rules into something that would work with JbossWeb (tomcat).
# Posted By Andy | 3/25/09 11:30 PM
Jamie Krug's Gravatar @Andy,

My pleasure. I think Apache mod_rewrite/mod_proxy make be the sensible alternative to mod_jk here, but I haven't had a chance to try it. A Stephane Carrez posted about using this to solve the very problem we have:

You could use the Tomcat rewrite engine instead of Apache, but then you'd either need to forward *all* requests from Apache to JBoss (instead of *.cfm/*.cfc only) or duplicate rewrite rules in both Apache and JBoss/Tomcat.

I'm liking the looks of the Apache rewrite/proxy solution. It also provides additional flexibility, like proxying different directories of a single domain to different JBoss contexts or ports, or even separate JBoss instances (if you have multiple apps under one domain that you'd like running on isolated JBoss instances).

I'll be sure to follow up here and maybe add another quick blog post once I've tried the rewrite/proxy solution.

I also discovered a way to place the Railo jars in a custom directory and tell JBoss, rather than having to drop them into a main lib folder, mixed with other non-Railo jars. I also discovered a way to specify directories to hold the Railo server admin and Web context directories WEB-INF folders, rather than having them generated within a main Tomcat lib folder and within virtual host Web roots. I hope to post all this soon...

# Posted By Jamie Krug | 3/26/09 10:39 AM
BlogCFC was created by Raymond Camden.