Menu

As simple as possible, as complex as necessary

Migrating from ColdFusion 9 to Railo 4.2

23 October 2014
Railo

ColdFusion 9 is due to be EOL-ed at the end of this year and we're considering whether or not to upgrade. We've held off doing so until now because the newer releases from Adobe have been insufficiently attractive to justify the cost.

Our preferred option is to move over to Railo, but we need to be sure that all our current CF9 apps will continue to work. So I've started the process of testing in the current "official" release (4.2.1) to see what breaks and how much adaptation work is involved.

Other lists of migration issues can be found online (such as Kai's, Jaime's and this StackOverflow question), but every app and environment is different, so I'm logging my own experience here as I go.

So far I've only tested one small app (my static blog generator) and this is what came up.

ORM: Secondary cache

Issue

Loading the app for the first time I got the following exception:

Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following:

  1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary
  2. Shutdown the earlier cacheManager before creating new one with same name.

The source of the existing CacheManager is: DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]

I use ORM in most of my apps and the built-in caching wherever I can, which requires the ormSetting secondaryCacheEnabled to be true in Application.cfc. My understanding of ehcache beyond that is poor though, and this error message meant little.

Fix

When I turned off the secondary cache and reloaded, the error went away. And strangely it hasn't returned despite re-enabling the secondary cache, clearing all clearable caches in the server admin, and restarting Tomcat/Railo. One of those dreaded "intermittent" problems then. Update: The error came back once the application timed out. Secondary cache is once again disabled.

Bug tracker

There seemed to be a number of related issues already logged but I chose to vote for 2233.

Update Raised against Lucee as Issue #96

ORM: identifier types

Issue

Bad identifier type: double at org.hibernate.engine.UnsavedValueFactory (etc...)

This one pointed to an entity identifer property definition:

property name="ID" fieldtype="id" type="numeric" generator="assigned" unsavedValue="-1";

Fix

Removing type="numeric" fixed it.

Update May 2015

On further investigation, the trigger seems to be the presence of both type="numeric" and the unsavedValue attribute.

An alternative to simply removing the type attribute is to change its value from "numeric" to "integer", but since type is supposed indicate a CFML type (rather than a database type), I'm not sure this is advisable. My preferred workaround is to replace it with ormType="int".

Ticket #305 has been raised against Lucee.

ORM: Inherited property persistent attribute

Issue

I have a library of base "MappedSuperClass" entities which individual apps extend and adapt. By default their properties are persistent, but in some apps a particular property isn't relevant and no column is created, so I "suppress" it by making it non-persistent in the sub-class: persistent=false. In other words I'm telling ORM not to query that field.

When loading one such entity, Railo threw a database exception complaining that the field didn't exist. It was clearly ignoring the overridden property persistence attribute.

Further testing showed that other properties could be overridden ok, and overriding persistent the other way round - from false to true - worked.

Fix

No fix, but as a workaround I resorted to setting all my base class properties to be non-persistent by default, and then enabling persistence for those I wanted to be queried. Not ideal.

Bug tracker

I seem to be the first to run up against this, so have opened ticket 3230.

Update Raised against Lucee as Issue #87

RSS feeds in cfscript

Issue

In CF9, <cffeed> is implemented via the sticking-plaster method of invoking methods on a CFC.

cffeed = New com.adobe.coldfusion.feed();
cffeed.create( name=myFeed,outputFile="feed.xml",overwrite=true );

Nice to be able to simplify this to:

feed action="create" name=myFeed outputFile="feed.xml" overwrite=true;

However, it seems the useful escapeChars attribute introduced in CF9 has been overlooked in Railo, since it threw an invalid attribute exception.

Fix

Back to the XmlFormat() days of CF8 I guess.

Bug tracker

Again, no-one else seems to have noticed this, so raised as enhancement request 3233. I've also tweaked the Railo Syntax Differences wiki page which didn't previously mention this small lacuna.

Includes in cfscript

Issue

Last, and least, this CF9 cfscript statement breaks in Railo

include "mytemplate.cfm";

Fix

include template="mytemplate.cfm";

You don't get more minor than this, but picayune as it may be, the award for simplicity goes to CF9 here.

Bug Tracker

There are more important things that need sorting.

Update: As Gert points out, the simpler syntax works fine. In fact, what Railo doesn't allow is a lack of space between include and the opening quotation mark of the template value:

include"mytemplate.cfm";//this will error in Railo but not in CF
include "mytemplate.cfm";//this works fine in Railo

Migrating from ColdFusion to Railo Part 2: Spreadsheets →

Posted on . Updated

Comments

  • Formatting comments: See this list of formatting tags you can use in your comments.
  • Want to paste code? Enclose within <pre><code> tags for syntax higlighting and better formatting and if possible use script. If your code includes "self-closing" tags, such as <cfargument>, you must add an explicit closing tag, otherwise it is likely to be mangled by the Disqus parser.
Back to the top