Running Railo and Adobe ColdFusion on the Same Context Root in JBoss

To make my applications run both on Railo ColdFusion and Adobe ColdFusion, I needed to make sure that code changes I was making for Railo did not break anything in Adobe CF. Initially, I set up two separate JBoss instances, one running AdobeCF and the other running RailoCF. However, it is a bit of a pain to start two servers, checkout content on both folders, sync files between two directories and so on.

A much nicer way is to get both AdobeCF and RailoCF to run on the same JBoss instance. That is actually not a problem if you can run them in different contexts (e.g., AdobeCF on /adobecf and RailoCF on /railocf). But in my case, I need to run them both on the same context root: /. Getting that to work is slightly more tricky but way more elegant. This is what I did:

Modify Hosts File

First thing, I created two entries in my hosts file (I use Mac). One for a host called railoapp.local and the other called adobeapp.local. Both pointing to 127.0.0.1.

127.0.0.1        railoapp.local
127.0.0.1        adobeapp.local

JBoss Server Instance

Next, created a JBoss (5.0.1) server instance by copying the “web” instance. Named the new instance as cfapps. By default the instance runs on port 8080.

Modify the jbossweb.sar/server.xml to have two more <Host> nodes

<Host name="railoapp.local">
<Alias>railoapp.local</Alias>
</Host>

<Host name="adobeapp.local">
<Alias>adobeapp.local</Alias>
</Host>

Make sure you put the nodes at the correct location.

Modify Apache Conf File

Added directives for the two virtual hosts in the Apache conf file. I normally use mod_proxy as it is fairly easy to configure and extend.

<VirtualHost *:80 >

ServerName railoapp.local
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/(.*)                    http://127.0.0.1:8080/$1 [P,L]
ProxyPassReverse /                    http://127.0.0.1:8080/
ProxyPreserveHost on
</VirtualHost>

<VirtualHost *:80 >
ServerName adobeapp.local
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/(.*)                    http://127.0.0.1:8080/$1 [P,L]
ProxyPassReverse /                    http://127.0.0.1:8080/
ProxyPreserveHost on
</VirtualHost>

If you are running JBoss server instance on another port you’d need to change the port number in the rewrite directives.

Restart Apache.

Deploy Adobe ColdFusion WAR

The next thing to do is to deploy ColdFusion WAR file. I have the exploded WAR file and created a folder called cfusion.war in the deploy directory the cfapps JBoss server. In /cfusion.war/WEB-INF, create a file called jboss-web.xml with the following content:

<jboss-web>
<context-root>/</context-root>
<virtual-host>adobeapp.local</virtual-host>
</jboss-web>

Deploy Railo ColdFusion WAR

Now deploy Railo WAR file. I have the
exploded WAR file and created a folder called railo.war in the deploy
directory the cfapps JBoss server. In the /railo.war/WEB-INF, create a file called jboss-web.xml with the following content:

<jboss-web>
<context-root>/</context-root>
<virtual-host>railoapp.local</virtual-host>
</jboss-web>

There is a known issue at the moment that if you deploy Railo as a WAR file, there are some conflicts with a few libraries. To avoid these conflicts, you need to remove the following JAR files from the Railo /railo.war/WEB-INF/lib folder

  • apache-xml-xerces.jar
  • xml-apis.jar
  • ss_css2.jar
  • tagsoup.jar
  • serializer.jar
  • w3c-dom.jar

That should do.

Start the JBoss server and look at the log output. You should see both AdobeCF and RailoCF start in the / context.

Place a file that dumps the server scope in cfusion.war and railo.war folders. Browse to http://railoapp.local/ you should see the server dump for RailoCF. Browsing to http://adobeapp.local/ should show you the server dump for Adobe CF.

Sharing Files Between AdobeCF and RailoCF

Since the basic idea was to make changes in the code and test in both AdobeCF and RailoCF, I checked out my application from source control twice — once into the webroot of cfusion.war and once into the webroot of railo.war. However, this was quite irritating and problemmatic as I has having to commit/checkout/update in two separate folders.

So I decided to remove the source code from cfusion.war and created symbolic links in cfusion.war folder to all the relevant folders in railo.war folder. So when I view the filesystem of cfusion.war I could see the relevant directories in the webroot.

However, JBoss Tomcat by default does not allow browsing to folders and files in symbolic links in the web context.

You need explicity tell it do so. To do this, you need to change jbossweb.sar/context.xml. Add allowLinking=”true” to the root Context node. This is what my Context.xml looks like:

<Context cookies="true" crossContext="true" allowLinking="true">
<Manager pathname="SESSIONS.ser" />
<Manager pathname="" />
<InstanceListener>org.jboss.web.tomcat.security.RunAsListener</InstanceListener>
</Context>

And that did it.

Restart the JBoss server. And now it should expose the linked folders as a regular folders in the webroot and you can browse to them.

It definitely made my development much easier as this setup provides an identical testing ground for my application (both apps running in the root context) and reduces logistical hassels like checking-out/checking-in files at two different locations.

4 thoughts on “Running Railo and Adobe ColdFusion on the Same Context Root in JBoss”

  1. Indy you’re a legend. Perfect timing as only yesterday started to look at deployment options for Railo.

    Few extras for the JBoss/Apache uninitiated:

    1. To start the cfapps server in windows, go to Command Prompt and run …

    run.bat -c cfapps

    2. You need to uncomment all the loadmodule calls in Apache httpd.conf (including all sub mods) for mod_proxy and mod_rewrite.

Leave a Reply to 2 Day Diet Japan Lingzhi Cancel reply

Your email address will not be published. Required fields are marked *