The World's Favorite Open Source GPL J2EE CFML Runtime Engine

BlueDragon Developer's Journal

Subscribe to BlueDragon Developer's Journal: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get BlueDragon Developer's Journal: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Open BlueDragon Authors: Reuven Cohen, Elizabeth White, Michael Sheehan, John Gauntt, Salvatore Genovese

Related Topics: Open BlueDragon Developer's Journal, ColdFusion on Ulitzer

BlueDragon: Article

CFDJ Feature - How to Debug Your ColdFusion Applications

Problem solving and techniques for your debugging adventures

With debugging code in place, I reloaded the template. Nothing was displayed. I switched to a different site and tried again, and the mode was properly displayed. It was empty, which was the default mode. That led me to believe there must be some sort of redirect that was being called in conditions that existed in the rogue site. In CF the most common method of redirect is to use a cflocation. I started pouring over the code looking for it. There was not an obvious redirect, but it may have been included in any one of a handful of includes or inside some CFC methods. Another tag came to the rescue, cfabort.

cfabort is used to stop the processing of a ColdFusion page. It has a single attribute, ShowError. The ShowError attribute accepts a string value, which is displayed to the screen before the templates execution is stopped. I added this line of code to the template before the switch statement:

<cfabort ShowError="It Got This Far">

I reran the template, but didn't receive the error message. That told me that the redirect was happening before the cfabort tag. By moving around the cfabort tag and I was able to isolate the line of code that caused the problem. It was a CFC method call that verified that the user was allowed to view this page. If the user didn't have access to view the page, then the system was actually operating properly (although some feedback would have been nice). I went back to the database to verify that my user had proper access to the database, and I did. Before the cfabort I added a dump of the user's access. Yes, the user should have access. This obviously wasn't the problem.

At this point, I take another in-depth look at debugging output. I noticed something I hadn't noticed before, as shown in Figure 3. There was an error executing the database query. With this new bit of information, I jumped over to the admin and verified the data source. Sure enough ColdFusion could not connect to it. This was probably the cause of the problem. I opened up the data source to discover that the username was incorrect. I corrected the username, verified the data source, and then loaded the trouble page again. Everything started working as expected. Finally!

Catching Errors
So the problem was a failed database query and not a cflocation redirect. You might want to ask why I didn't see a ColdFusion syntax error if the database query failed, right? Good question, it shows that you are thinking. The answer is simple. The error was caught and the user was redirected to the "empty" index page. In this case the site was using the cferror tag to catch the error. cferror is a tag that you would normally put in the application.cfm to launch a specific error page when an error occurs. In CFMX7 you can also use the OnError event that is part of Application.cfc. More information about the cferror tag can be found at htmldocs/00000242.htm#2022557. Information about the OnError method is found here: htmldocs/00000697.htm#1188543.

cferror usually redirects the user to a page that can process the error, usually displaying a nice error message to the user, logging the error, and/or sending an e-mail to notify a developer about the error. Unfortunately, this particular cferror tag just redirected the user to the site home page, which masked the error from my view. It is an internal site, which unfortunately, often gets fewer resources than the public-facing site, and I'm sure the error page was something that just hasn't been implemented for this site.

Where to Go from Here
What do you want to look at next? If you're a BlueDragon user you can take a look at cfdebugger, which writes detailed information about the code that is executed to a file. More information about cfdebugger is in New Atlanta's enhancement guide, located here: 6_2/BlueDragon_62_CFML_Enhancements_Guide.pdf, and it was written about in the November 2003 article of CFDJ. At CFUnited, New Atlanta also announced the BlueDragon Profiler, which will allow you to get line-by-line details of a templates execution.

It is also worth noting that you can create your own debug templates for ColdFusion. The classic and dockable styles are located in the web-INF\debug directory of your ColdFusion installation. You can use them as a start to roll your own. Put your new debug template into the same directory and it will show up in the Administrator under debug settings.

More Stories By Jeffry Houser

Jeffry is a technical entrepreneur with over 10 years of making the web work for you. Lately Jeffry has been cooped up in his cave building the first in a line of easy to use interface components for Flex Developers at . He has a Computer Science degree from the days before business met the Internet and owns DotComIt, an Adobe Solutions Partner specializing in Rich Internet Applications. Jeffry is an Adobe Community Expert and produces The Flex Show, a podcast that includes expert interviews and screencast tutorials. Jeffry is also co-manager of the Hartford CT Adobe User Group, author of three ColdFusion books and over 30 articles, and has spoken at various events all over the US. In his spare time he is a musician, old school adventure game aficionado, and recording engineer. He also owns a Wii. You can read his blog at, check out his podcast at or check out his company at

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

Most Recent Comments
CFDJ News Desk 10/21/05 09:26:15 PM EDT

CFDJ Feature - How to Debug Your ColdFusion Applications. I just spent four hours debugging an error for a client. The client is an application service provider, and they developed an administrator for internal use. The administrator allows for the user to switch between sites, at whim. The 'site switcher' is a drop menu, which loads up a different DNS depending on the selected site.