Coldbox mystery. Well at least to me.

Hello all. I have a little bit of a problem and I was hoping to send it out to the list for thought.

The setup:

I asked the list a little while ago about creating some code to check the DB to see if it was there before processing anything. Of course, if there is no problem the page
would load and porcess normally however, if for some reason the DB was not online, we have the option of: changing the data source to the backup DB (future) or displaying a nice
friendly message to the user that the DB was down and the admin staff has been notified.

It was suggested that we use and interceptor to accomplish this task. So far, this is working fine but I noticed an issue when I started testing this code.

First, let me give you a little peek into the directory structure:


The projects have their own coldbox structure inside so they are separate from each other and they don’t interact.
Example: /var/www/html/project1 has the following directories: config, handlers, includes, interceptors etc just like a “normal” CB project would.

This is an example of the interceptor that is present in all of the projects:

component extends=“coldbox.system.Interceptor” {

void function configure(){


function checkDatabase(event) {
var rc = event.getCollection();
rc.i = 0;

do {
rc.i += 1;
qQuery = new Query();
qSql = “select 1 from dual”;
result = qQuery.execute();
//metaInfo = result.getPrefix();
//records = result.getResult(); ;

} catch (any e) {

if(rc.i == 7) {
rc.msg_type = ‘database’;

//We only want to send mail if the environment is PROD
if(getSetting(“Environment”) == “PRODUCTION”) {
// Get new mail object
mail = getPlugin(“MailService”).newMail().config(from=“webmaster@”,
subject=“Database Failure #application.application_name#”);
// create some tokens
tokens = {appname=application.application_name, date=dateformat(now(),“full”), time=timeformat(now(),“full”)};

// Set some body text

Application = @appname@

The Error Occured:@date@ @time@.


// Send the mail
results = getPlugin(“MailService”).send(mail);

} while (rc.i <= 10);



Ok so, when everything is fine, this will not throw an error and everything is right with the world. To test this, I just went to the DSN on the CF Admin side and changed the user name of the so that the login would fail and it will simulate a DB problem. *Please note I changed the emails and the DB name for posting and left out the domain name. Also, in each respective project this line: location("/project1/views/error.cfm?"&“msg_type=”&rc.msg_type); changes with the project. So in project2 its: location("/project2/views/error.cfm?"&“msg_type=”&rc.msg_type); and so on.

Now, when this runs with the DB “broken” I will get an email if its on production and it will go to the error page informing the user that the DB is down and will land in the project1/views/error.cfm page

However, I have noticed that if I run this on project1, with the DB in a “broken” state, everything is fine, but if I then go and run this on project2 it will throw the error but always end up here: project1/views/error.cfm.
The same thing will happen with project3, 4 etc. This will not “fix” itself until I restart coldfusion and “fix” the DB. To make things even more confusing, say I make a “reset” of everything,
and then “break” the DB but go to project4 first. We will get the DB error and then end up here: project4/views/error.cfm and so will every other project that “trips” that error.

Does coldbox save some information or something that I don’t know about ? I have also been trying to follow this all the way with the debugger to see if I can detect the moment when the switch is made.
So far, I haven’t made it all the way through as there is a lot of coldbox code to step through or skip over.

If anyone has any suggestions or corrections or needs any other information, please let me know.

Thanks in advance!


Hi Mallory,

Two quick questions…

Is there any reason you’re using location() instead of setNextEvent() / setNextRoute()? Using one of those you could easily locate to an error event and no project number would have to be hard-coded at all…

Also, do the applications all have unique application names and appName settings in their configuration? see appName in your Coldbox.cfc… and the application name in your Application.cfc

Oh, and what does your interceptor declaration look like?


Go into you ColdFusion CFIDE Administrator and remove the option Component Cache in the caching section, this has been discussed in here many times.

If you are running more than one application on your server, then it is a MUST that this option be switched off.


Jim and Andrew,

Thanks for taking the time to answer my question. I went with the solution of turning off the cache in CFAdmin. When I mentioned this to my boss, he told me of another time he had encountered this but he was able to work around it.

Thanks so much and this makes this a good Friday for me. Two Virtual Beers for you both until I can buy you real ones.