ColdFusion Intermittently Cannot Find CFC, Part II

Ok, follow up to yesterday's post "ColdFusion Intermittently Cannot Find CFC". I've updated my tests and still no answers. Help me figure out why ColdFusion sometimes doesn't want to CreateObject().

 

ColdFusion Intermittently Cannot Find CFC

Ok, so a new one on me... ColdFusion has started to intermittently fail to find a CFC when trying to instantiate it. I started getting emails that the system was erroring out because it failed to find a component for part of a process in our system, but when I went back to try it myself, things worked fine. I dismissed it as odd until it started to happen more often. Click "more" to see how I replicated the problem and help me figure out what is going on.

 

Utility Functions: ListIsValid() and ListRemoveInvalid()

A gear One technique I often use is to create gateway objects to my database that allow the user to pass in multiple IDs, rather then a single one. I've run into a problem though; what if the user passes through something that is a valid list, but is not a valid list of the type I need? Read more to see ListIsValid() abd ListRemoveInvalid().

 

Utility Functions: CreateMapping() and RemoveMapping()

Some more "stolen" code for today's pair of utility functions. Thanks to FusionGrokker's post on controlling mappings in CF7. As FusionGrokker points out, these functions work in CF7, but its actually hacking global mapping values, so you could have problems.

<cffunction name="CreateMapping" output="false" returntype="void">
    <cfargument name="mapping" type="string" required="true" />
    <cfargument name="path" type="string" required="true" />
    
    <cfset var factory = CreateObject("java", "coldfusion.server.ServiceFactory") />
    <cfset var mappings = factory.runtimeService.getMappings() />
    
    <cfset mappings[arguments.mapping] = arguments.path />
    
    <cfreturn />
</cffunction>

<cffunction name="RemoveMapping" output="false" returntype="void">
    <cfargument name="mapping" type="string" required="true" />
    
    <cfset var factory = CreateObject("java", "coldfusion.server.ServiceFactory") />
    <cfset var mappings = factory.runtimeService.getMappings() />
    
    <cfset StructDelete(mappings, arguments.mapping) />
    
    <cfreturn />
</cffunction>

 

Multi-Server Transactions with CFThread

Braided ThreadsI ran into an interesting problem today: I have an application where I need to add a user record to one server, and also conditionally add some records to another server for that user. Problem is that this needs to be inside a transaction, and ColdFusion doesn't allow multiple server connections inside a transaction, even if they are on the same datasource. To get around this, I employeed <cfthread/>. Click "read more" to ready how.

 

FireFox 3.0 and Hosts Files

FireFox logoI discovered something interesting today: FireFox 3.0.X periodically reloads your hosts file while running.

I'd been using IE7 and Chrome when working with my code recently, but today I'd had a Chrome specific bug and fired up FF as a double check. While it was running I needed to view something on the unmodified version of a URL I'd overridden, so opened my hosts file, updated it and then launched a new browser to check out the other version. After about 5 minutes I refreshed the FF page, and suddenly I get a warning that the file doesn't exist. At first I thought I'd deleted something, but it turns out that FF update from the host and was now requesting the site where the file didn't exist, instead of my development version.

I reverted my host file and refreshed for a bit, and sure enough, suddenly it switched back to the development version. As far as I'm aware, FF3 is the only browser that updates its host file while running; every other browser seems to only load it on start and then to hold onto that result.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.