The major problem that comes when letting applications run from a CD is the fact that the CD (ROM) is as its name already states read only memory. There is no possibility to write any data to the filesystem on the CD. So we need to think of something different.
Here are some of the things that can come into play:
- directory placeholders
- resources
- readonly Railo archives
- absolute pathes
But now let's create a CD-version of a sample machII application step by step. For my example I use the MachII sample application Contact Manager. I will create a simple version with some preconfigured mappings. When creating a CD version of an application you need to be aware of every process that writes files somewhere. In Railo these processes are listed : below:
- compilation of .cfm and .cfc files
- configuration changes in Railo (if you for example would like to add a mapping or datasource at runtime)
- runtime logging
- on the fly creation of files (like the parsed files in fusebox)
- database or other writing operations
Download a current version of Railo Express
Go to the website, click on the download link and select the Railo Express version. Or you might navigate to the customer center and download the latest Release Candidate of Railo 2.0.
Unpack Railo Express into a local folder and start it
The downloaded zip-file can be unpacked into any folder on the local hard disk drive. After unpacking just execute the start (.bat or .sh) file. Railo will be started on Port 8888. Now navigate in a browser to http://localhost:8888/railo-context/admin.cfm and start the railo web administrator. The password you define here will be the one used when creating further mappings or datasources or whatever on application startup. It might for example be necessary to copy some files into the temp folder and create a datasource pointing to them. Since you can not create a datasource with a virtual path (containing directory placeholders), you need to create the datasource on first startup.
Configure Railo the way you need it
For MachII there needs to exist a mapping named machII which points to the machII core files. On the CD the webroot directory will be the main directory for the application that is on the CD. If you need to write to some directories, you can either copy all files to the temp directory which is represented by the directory placeholder {temp-directory} and create a mapping named "/" which physically points to the {temp-directory}. To copy files just use the syntax below.
<cffile action="COPY" source="/copysource/file.txt" destination="#ExpandPath("{temp-directory}")#/railo/copytarget">
With this sollution you can copy already filled databases (HSQLDB or H2) to the local temp directory and create a datasource on first application
startup. Then you might even be able to use a database within your CD application.Copy all necessary files and content to the Railo Express webroot.
Now copy all MachII core files and static assets to the webroot and configure your application so that it works correctly.
Open the file /lib/railo-server/context/railo-server.xml. In this file everywhere where files are written or files are changed you need to change the value for the file beeing used to the ram resource or to the systems temp directory. So entries like this one:
<mail log="{railo-web}/logs/mail.log" spool-enable="yes" spool-interval="5" timeout="30">
</mail>
need to be changed into this:<mail log="{temp-directory}/<b>RailoTemp</b>/logs/mail.log" spool-enable="yes" spool-interval="5" timeout="30">
</mail>
I tend to use a certain folder in the temp directory for all the files that are used by Railo, so that everything is grouped.
The code below contains an exaple for the railo-server.xml file.
<?xml version="1.0" encoding="UTF-8"?><!--
Path placeholders:
{railo-web}: path to the railo web directory typical "{web-root}/WEB-INF/railo"
{railo-server}: path to the railo server directory typical where the railo.jar is located
{temp-directory}: path to the temp directory of the current user of the system
{home-directory}: path to the home directory of the current user of the system
{web-root-directory}: path to the web root
{system-directory}: path to thesystem directory
--><railo-configuration password="a233fcc79ee606ce0ee9c345bb41d8b49be3cf5c596e9396">
...
<system err="default" out="default"/>
...
<data-sources preserve-single-quote="yes">
</data-sources>
...
<file-system fld-directory="{railo-server}/library/fld/" temp-directory="ram:///temp/" tld-directory="{railo-server}/library/tld/">
</file-system>
<resources>
...
<default-resource-provider arguments="lock-timeout:1000;" class="railo.commons.io.res.type.file.FileResourceProvider"/>
...
<resource-provider arguments="lock-timeout:20000;socket-timeout:-1;client-timeout:60000" class="railo.commons.io.res.type.ftp.FTPResourceProvider" scheme="ftp"/>
...
<resource-provider arguments="lock-timeout:1000;case-sensitive:true;" class="railo.commons.io.res.type.zip.ZipResourceProvider" scheme="zip"/>
...
<resource-provider arguments="lock-timeout:1000;case-sensitive:true;" class="railo.commons.io.res.type.tar.TarResourceProvider" scheme="tar"/>
...
<resource-provider arguments="lock-timeout:1000;case-sensitive:true;" class="railo.commons.io.res.type.tgz.TGZResourceProvider" scheme="tgz"/>
</resources>
...
<scope applicationtimeout="1,0,0,0" cascade-to-resultset="yes" cascading="standard" clientmanagement="no" merge-url-form="no" requesttimeout="0,0,0,50" requesttimeout-log="{railo-web}/logs/requesttimeout.log" sessionmanagement="yes" sessiontimeout="0,0,30,0" setclientcookies="yes" setdomaincookies="no"/>
...
<mail log="{temp-directory}/RailoTemp/logs/mail.log" spool-enable="yes" spool-interval="5" timeout="30">
</mail>
<mappings>
...
<mapping archive="{railo-web}/context/railo-context.ra" physical="{railo-web}/context/" primary="physical" readonly="yes" trusted="true" virtual="/railo-context/"/>
</mappings>
<custom-tag>
<mapping physical="{railo-web}/customtags/" trusted="yes"/>
</custom-tag>
<cfx-tags>
<cfx-tag class="railo.cfx.example.HelloWorld" name="HelloWorld" type="java"/>
</cfx-tags>
...
<component base="/railo-context/Component.cfc" data-member-default-access="public" dump-template="/railo-context/component-dump.cfm">
</component>
...
<regional timeserver="pool.ntp.org"/>
...
<debugging debug="yes" log-memory-usage="no" memory-log="{temp-directory}/RailoTemp/logs/memory.log" template="/railo-context/templates/debugging/debugging.cfm"/>
...
<application listener-mode="curr2root" listener-type="mixed"/>
<update location="http://www.railo.ch" type="manual"/>
</railo-configuration>Now the railo-server.xml is customized so that it will run correctly from a CD. Now we have to change all settings of the railo-web.xml accordingly. Here I will discuss some of these settings. First of all we need to adapt the compilation target and the Railo temp directory. At the moment Railo compiles into the folder WEB-INF/railo/cfclasses. We can easily change this into the following:
<file-system deploy-directory="ram:///cfclasses/" fld-directory="{railo-web}/library/fld/" temp-directory="ram:///temp/" tld-directory="{railo-web}/library/tld/"></file-system>
Now Railo compiles into the computer's ram since the ram resource is available by default and can be used anywhere within Railo. I have placed the
temp directory of Railo into the ram as well.You could in fact use the ram for nearly all of your file writing operations. Except if you would like to access the files from outside (like log files) or if database drivers rely on exact physical pathes.
Now you can burn your CD
After having done all this, you can create your CD with an autorun.inf file which will execute automatically. The only things that have to be executed on CD start are the start.bat and calling the url http://localhost:8888/contactManager/index.cfm
3 responses so far ↓
1 AJ // Aug 12, 2007 at 1:35 AM
By Railo Express, do you mean
Railix (Live Version) ?
2 Gert Franz // Aug 12, 2007 at 11:52 AM
yes. We renamed the Railix Version to Railo express since we wanted to have the name 'Railo' in all of our different versions. It could be confusing that Railix has no relation to Railo :-)
Gert
3 Jeff // Aug 16, 2007 at 3:18 PM
Leave a Comment