Skip to main content
WolfShade
Legend
October 28, 2011
Question

Bizarre error - highly illogical, captain.

  • October 28, 2011
  • 2 replies
  • 824 views

Hello, everyone.

I have two websites that I developed in 2005 (yeah.. the client is still using them as originally developed) that are now exhibiting a very weird error.

Starting last year, every few weeks, if the client does not go into the application.cfm file and change the name of the CFAPPLICATION tag by appending and changing a date as part of the name, then it will throw an error "Context validation error for CFCATCH tag (the tag must be nested inside a CFTRY tag)".

For one of the sites, the application name was originally MAA.  The client added "_RE101009" to it, and it then works.. for a few weeks.  Then the client will change it to MAA_RE111109, and it will work flawlessly.. for a few weeks.  And it keeps going, and going.  So, now it's called MAA_RE121211.  (I know!)  Same thing for the second site (although, a different prefix before the _).

At first, I suspected that the issue might be because they were originally written in either CF5 or CF6, and now one site is on CF7, the other on CF8.  But I can't think of anything that I used that has been deprecated in these later releases.

Has anyone else run across this issue?

Thanks,

^_^

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    October 30, 2011

    Changing the name in the cfapplication tag effectively restarts the application from scratch. As far as ColdFusion is concerned, each time you change the name, you are starting a brand new application, completely different from any previous one with another name.

    Connect this to what Adam has said, and you will find that your code has, each time, been running the same logic, but then under a new name. The error is obvious enough. Somewhere, your code attempts to execute a cfcatch tag without first having executed a cftry tag.

    Turn debugging on in the ColdFusion Administrator. ColdFusion should then tell you where the error occurs. 

    Alternatively, usually a more preferable and quicker solution, search in your editor for all occurrences of cfcatch. Then check them one by one to see if they are, irrespective of the code logic, always within a cftry tag. Pay particular attention to this rule from the official documentation: "The entire cftry tag, including all its cfcatch tags, must be on a single ColdFusion page".

    WolfShade
    WolfShadeAuthor
    Legend
    November 4, 2011

    Thanks for the replies, guys. Sorry for taking so long to respond.

    Only time will tell if it worked. I still don't know what could be

    causing some kind of "build up" that kills the process, nor why changing

    it will clear it up, but I think I've isolated the code. I've commented

    out the offending CFCATCH (I think) that appeared to be improperly

    nested. Don't know how it got in there, but it was from a LONG time

    ago. So, who knows.

    Thanks, again.

    Inspiring
    October 28, 2011

    I don't think it's that bizarre.  What it suggests to me is that there's a logical path through your app that only gets executed when some sort of threshold is reached in your app (a certain size of application scope variable, or a variable overflowing its capacity, or something similar with a DB column etc), and this is mitigated by resetting the application scope. And when this logic path runs, it tries to include the file with the syntax error.

    If you switch robust exception handling on, the error will also tell you which file it's in, and pin-point the line around about where the syntax error is.  Fix it.  It's not a logic error or anything like that, it's just invalid code that doesn't compile, so it should be a no-brainer to sort out.

    From there you should be able to work back through the logic and work out what the condition is that causes this logical path to execute, and you might find you need to tidy up some other code too, to fix or improve the situation that's causing all this to happen.  But simply fixing your syntax error would be a good place to start.

    --

    Adam