Application.cfc lookup order change in ColdFusion 9

This post is more than 2 years old.

In previous versions of ColdFusion, the server would look for an Application.cfc (or CFM) file in the current folder. If it didn't find it, it would begin to 'crawl up' the folder hierarchy until it reaches the root of the drive.

ColdFusion 9 adds the ability to modify this behavior. In the ColdFusion Administrator, Settings panel, you will see the following new option:

Now the first two options make sense. The 'Default order' option is the same as the previous version of ColdFusion. The next option, 'Until webroot', will tell ColdFusion to only search until it gets to the root of the web server. The last option, 'In webroot', didn't make sense to me.

I read it as "Only look for the file in the web root", but that is not the case. If you have an Application.cfc file in the same folder as the CFM being executed, it is still executed. What changes with this option is what happens with a deeply nested file. So consider the following folder structure: WebRoot/products/weapons/. If I execute a CFM in the weapons folder, and there is no Application.cfc file there (or .CFM of course), then ColdFusion will skip the products folder and only check WebRoot.

All in all, I'm not sure I'll use either of these two new options. I'll typically place my Application.cfc file at my project root, which is typically one folder higher than my web root. I'd have to use the default option in order for that to work.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Sean Corfield posted on 8/18/2009 at 11:17 AM

Railo has had similar functionality for quite a while. I wonder if Adobe have implemented the same way (good) or differently? I haven't tested the Railo options in depth but now seems like a good time to do so...!

Comment 2 by Raymond Camden posted on 8/18/2009 at 3:35 PM

I'm curious though - do you think the third option makes sense? I don't think it is a bad option per se... just... weird I guess.

Comment 3 by Gary Funk posted on 8/18/2009 at 4:48 PM

I am a little confused. What is the difference between Default Order and Until webroot?

Comment 4 by Raymond Camden posted on 8/18/2009 at 5:20 PM

Default means to look until the root of the file system.

Comment 5 by Gary Funk posted on 8/18/2009 at 5:45 PM

So default goes past the webroot? I never knew that .

So if my webtoot is c:\www\fsoft and I don't have anApplication.cfc there, it will keep looking and if it finds Applicatin.cfc in c:\, it will use that one. That could get quite nasty if one were to not know this.

Comment 6 by Raymond Camden posted on 8/18/2009 at 7:36 PM

Yes - the default behavior is to go to web root.

Comment 7 by Sean Corfield posted on 8/18/2009 at 8:12 PM

I think most ppl put Application.cfc in the web root or in their application root so the third option is for performance (since it means "Only look in these two places"). The Application.cfc lookup is done on every request so if you have either a deeply nested application or you don't have Application.cfc/.cfm at all (unlikely, but I've seen it happen), then the engine has to look in a lot of directories. Nearly all of the Railo Administrator settings like this have to do with performance, offering compatibility with Adobe in one setting but the option to be less compatible in exchange for better performance in other settings.