Earlier this year Sean Corfield blogged about a “multi-web” install of Railo on Tomcat.
I decided to see if I could set up a similar configuration on JBoss 5.1.0 and was able to do it successfully by following Sean’s steps with a few modifications. These modifications are documented below.
My solution also includes some ideas I learnt from this blog post – http://help.shadocms.com/blog/2009/running-railo-and-adobe-coldfusion-on-the-same-context-root-in-jboss.cfm
Firstly, I took a copy of the jboss “web” instance and named it railo, ie:
copy <JBOSS_HOME>/server/web to <JBOSS_HOME>/server/railo
This will become our railo server instance.
NB: <JBOSS_HOME> is the directory where I installed JBoss – in my case c:/jboss/jboss-5.1.0.GA
Now I started following Sean’s instructions. The first issue I ran into was when I came to edit the conf/catalina.properties file. I could not find the JBoss equivalent (there may be one, but I just couldn’t find it). However I found that by putting the Railo JARs into <JBOSS_HOME>/server/railo/lib this had the same effect.
Next Sean mentioned editing the Tomcat conf/web.xml file. The corresponding JBoss file to edit is:
<JBOSS_HOME>/server/railo/deployers/jbossweb.deployer/web.xml
At this point we we can start the server and have a look at the server administrator. To do this (on windows at least) go into the command prompt, cd to <JBOSS_HOME> and run this command:
bin\run -c railo
Once it starts up, you can then browse to http://localhost:8080/railo-context/admin.cfm to view the Railo Server Administrator.
After confirming it runs, stop it again (I just use CTRL-C to stop the JBoss instances – there may be a cleaner way but I am not aware of it).
The next thing in JBoss that differs from the Tomcat instructions is adding your new host definitions. In Tomcat this is done in conf/server.xml, but in JBoss 5.1.0 it is done in <JBOSS_HOME>/server/railo/conf/bootstrap/profile.xml.
The change I made to this file is shown below:
<!--
The profile configuration
This contains required properties:
The uri to jboss-service.xml.
The uri to the deployers folder.
A list of uris to deploy folders. -->
<bean name="BootstrapProfileFactory">
<property name="bindingsURI">${jboss.server.home.url}conf/bindingservice.beans</property>
<property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
<property name="deployersURI">${jboss.server.home.url}deployers</property>
<property name="applicationURIs">
<list elementClass="java.net.URI">
<value>${jboss.server.home.url}deploy</value>
<value>file:///C:/www/railo-deploy</value>
</list>
</property>
<property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
<property name="profileFactory"><inject bean="ProfileFactory" /></property>
</bean>
Note that this is a URI, so it must include file:/// (this caught me out on my first attempt). How I did this was to create a directory called c:/www/railo-deploy, then in that directory create new directories called web1.war and web2.war
Next (borrowing from the ShadoCMS blog) <JBOSS_HOME>/server/railo/deploy/jbossweb.sar/server.xml to have two more <Host> nodes:
<Host name="web1.local"> <Alias>web1.local</Alias> </Host> <Host name="web2.local"> <Alias>web2.local</Alias> </Host>
The final piece of the puzzle was then to create a web.xml and jboss-web.xml in each of the WEB-INF dirs, ie:
c:/www/railo-deploy/web1.war/WEB-INF/web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Web App 1</display-name> <description> Railo Web 1 </description> </web-app>
c:/www/railo-deploy/web1.war/WEB-INF/jboss-web.xml
<jboss-web> <context-root>/</context-root> <virtual-host>web1.local</virtual-host> </jboss-web>
c:/www/railo-deploy/web2.war/WEB-INF/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Web App 2</display-name> <description> Railo Web 2 </description> </web-app>
c:/www/railo-deploy/web2.war/WEB-INF/jboss-web.xml
<jboss-web> <context-root>/</context-root> <virtual-host>web2.local</virtual-host> </jboss-web>
All going well you should now have a working multi-web setup in JBoss.

This work is licensed under a Creative Commons Attribution-Share Alike 2.5 Australia License.
Post a Comment