OnRequestEnd behavior changed in CF9 (was Request Variable Bug in ColdFusion 9)

Here's a weird one. I haven't had any luck finding any information about this on Google, so I'm wondering if any of you have seen this before?

I've got a CFC in the request scope and then in the onRequestEnd event I grab that CFC out of the request scope and do some end-of-request stuff with it. The problem is I can't reference the variable in my onRequestEnd event because it produces an error that says it's not defined in the scope... but here's where it gets really weird and why I KNOW this is a bug (it's not just a suspicion)... If I DUMP the variable, the cfdump tag successfully displays the CFC and all its stuff... and then produces the same "is undefined in scope" error. Here's a screen-capture.

So... anybody seen this before? 'Cause I'm totally stumped. I've already installed the 9.0.1 updater and both of the cumulative hot fixes.

p.s. Yeah, I know it says OnRequestEnd.cfm, but this is actually inside the Application.cfc onRequestEnd method -- it's a legacy from the framework dating back originally to CF5, just go with it. ;P

Okay, it just got weirder... I tried using evaluate() to set it to a local variable, which apparently works because then I dump the local variable and the dump still works even though it's now on line 2 AFTER line 1 where the error is still occurring.

EDIT: Here's the code from the Application.cfc that includes the file where the error occurs:

<cffunction name="onRequestEnd" access="public" output="true">
<cfinclude template="OnRequestEnd.cfm">

It appears to have something to do with the combination of the method and the include file.

It still fails if I execute the method in the onRequestStart like this:

<cffunction name="onRequestStart" access="public" output="true">
<cfset onRequestEnd() />

But it works fine if I include the file in onRequestStart like this.

<cffunction name="onRequestStart" access="public" output="true">
<cfinclude template="OnRequestEnd.cfm">

HOWEVER! There's obviously more to this because I can't create a simple test case. If I create a new project with a very simple application.cfc in it and replicate all these details, it works fine. So there's something else in the framework that's contributing to it beyond just the method names and file names.

And the file name doesn't seem to actually contribute, since it still fails in the same way if I change the name of the file like this:

<cffunction name="onRequestEnd" access="public" output="true">
<cfinclude template="reqend.cfm">

Okay it has nothing to do with the file... well it does, but not with the file name... At the bottom of the onRequestEnd.cfm is this code

<!--- this seems to help resolve a leaky-memory issue in CF/JRun --->
<cfset structClear(variables) />
<cfset structClear(request) />
<cfabort />

If I comment out those StructClear statements, then the error goes away, which told me that it was executing the OnRequestEnd.cfm twice... and I THINK that means that CF9 changed the behavior of the CFABORT tag and it now executes the onRequestEnd event when the tag is used... it didn't in previous versions of cf...

I didn't find documentation of this, but I did find this blog from Ben Nadel that mentions it also occurring with CFLOCATION, so it seems to be more generally about the onRequestEnd event. It seems now in CF9, no matter how a page finishes executing, the onRequestEnd event is executed at the end... That's a change from all the previous versions and so it mucks with code I had created in order to actually cause this to happen on previous versions. Since I was causing execution of the onRequestEnd and then aborting the page early, CF now executes the onRequestEnd, aborts and then executes the onRequestEnd again because of the abort. (I tested to see if this happens with an OnRequestEnd.cfm and it doesn't -- it's just the Application.cfc method.)

Luckily, this fairly simple bit of code at the top of the template seems to fix the problem:

<cfif structIsEmpty(request)>
   <cfexit method="exittemplate" />

Collaboration Chat - the Sequel

Tomorrow, Tuesday around 6pm Central I plan to open up the CF Community Collaboration Chat room again for another session. This is an informal discussion of tools and techniques for improving collaboration within the ColdFusion community and encouraging integration between various open-source (and/or commercial) projects.


In the weeks since the first chat, we've made good progress on the FreeAgent project, which is designed as a system for creating applications that can be easily installed into any of the MVC frameworks for ColdFusion. I'll talk a bit about what we're doing with this project, and probably show some code and I hope as well that some of you will bring your thoughts, tips, tools and techniques that you've used to create integration between projects. Or even just your thoughts on the subject, since this isn't something we see much in the community yet. :)

Had a great time last time, and although I know this is short notice, I expect to have a good fun session this time as well. :)

See you there!

Collaboration Chat Recording

I'm new to hosting discussions with Adobe Connect. ;) And it's taken me a little bit to figure out how to find the recording URL for the collaboration discussion we had the other day.

For an informal chat on relatively short notice, I think we had a good turnout and I really enjoyed the discussion. :) Sean Corfield dropped in briefly while at a cat show in So Cal, Andy Scott, Dominic Watson and several others.

Here is the recording of our chat:


I don't hear any problems with the audio in particular on this recording. I was listening over it and Tiffany said that there's a whistling on the recording that made it rather difficult for her to listen to. I don't hear it. I don't know why. Sean Corfield had showed up briefly and also mentioned a whistling sound during the chat, so maybe he was hearing the same thing. I wish I knew what it was.

I also discovered a small bug(?) in the Connect login. The login URL I was given for my account was https://admin.na3.acrobat.com/system/login but I was having problems being unable to log in at that URL. I ended up having to use the "forgot password" feature several times, but the problem wasn't that I'd forgotten it. I would get the reset password URL in my email, go reset the password, and then log in fine, but then I would log out and be unable to log back in. It turns out that when I went directly from the reset-password page to the login, it added a URL parameter to the login url of ?next=/ so the full URL was https://admin.na3.acrobat.com/system/login?next=/ and without that URL parameter, it would never let me log in. But that's not the URL I was given in the original email when my account was set up. Hopefully that will be helpful to someone else who might be having the same problem.

Community Collaboration Chat

I have an active interest in collaboration within the ColdFusion community, particularly between projects. On Sunday, I'd like to talk about ways that we can foster more integration between various projects.

For example, there's Mango Blog that Laura Arguello did an excellent job with, there's Ray Camden's Galleon Forums and there's Codex Wiki written in ColdBox and Transfer. And I might like to run all of these, but they're written on different frameworks (or no framework) and generally built as stand-alone apps. So how do I integrate these seamlessly into a single website or extranet, without having to make wholesale changes to the code that would make upgrading later a major challenge?

Some of us have already done some work in this arena. For example, Laura did an excellent job with Mango Blog in creating a delegated login option. But these great innovative integration features aren't widely known and for many challenges it seems that none exist at least in common usage within the community.

This chat is an open invitation for anyone in the community who's interested in improving collaboration between projects, to discuss the projects we've worked on, the challenges we've faced and solutions we've created or potential solutions we'd like to see.

I hope you'll join us. :)

Time: 3PM CST Sunday, Nov 15th (1PM Pacific, 4PM Eastern)

New Model for Caching - Revisited

I'm still a bit surprised that this cache article is one of the more popular entries on the onTap framework blog. Surprised, and also flattered. :) Some of the information in that article turned out to be inaccurate because of something I discovered in my testing shortly afterward. In the original article I had proposed using a query to manage cache and although I've kept the query because it's rather useful for reporting and bulk-removal purposes, I've ultimately ended up with a hybrid solution that uses both the query and a structure to get the best of both worlds. It's taken me a while to get back to work on it because the past year has been pretty busy for me, but I'm finally nearing a 1.0 release candidate for the CacheBox project. I still need to work out a few issues, but it's coming along rather nicely. :) Soon I'll be updating DataFaucet and the onTap framework to use CacheBox Agents as an upgrade from the caching that's built into them currently.

onTap Framework Presentation Thursday

I'll be giving a presentation on the onTap framework this Thursday for the online ColdFusion User's Group. If you're not familiar with the group, you can check out their site at coldfusionmeetup.com. I'm looking forward to it, I think this will be one of my best presentations yet.

Although today I was having a miniature heart-attack because I plan to give the presentation from my new notebook and discovered a strange issue with Apache. I just recently picked up this HP Touchsmart notebook and when I got it I decided to go for the 64-bit Vista Ultimate option. All-together I have actually been very happy with it. With 4GB of RAM, even with the Vista extras and the HP preinstalled whatever, it's still much faster and usually a bit more stable than my previous notebook. I've only run into a couple of hiccups. One is that the video drivers were causing crashes when I was trying to use a 2nd monitor, which is an issue with the driver manufacturer, not with Microsoft. It also occasionally drops the driver for the stylus, which I think is N-Trig's issue (and Adobe isn't supporting pressure sensitivity with the N-Trig tablets yet, which is Adobe's issue). But today's was a weird one!

I realized that I hadn't really done significant work on the frameworks on this new machine and I was loading up a brand-new copy of the onTap framework to test for the demo. I unzipped it clean and went to it on localhost. And then I realized that everything was taking great heaps of time to run. Everything else on the machine was still snappy as ever, but the CF server was dogging! The plugin manager was taking almost two solid minutes to load. I remembered it being only a few seconds on the other machine, and that's for a heavy-duty page. So I fired up the old machine, and sure enough, the same page that took 2-minutes on Vista was loading in a few seconds on XP. So I checked all my version information to make sure I wasn't missing a CF update or a hotfix or something on the new machine and nope, CF is identical on both machines.

After scrounging around a bit, I ran into this thread on the Apache forum about slow requests to the localhost.

What the hell? Why is a request to the localhost slower than a request to the outside world? But I tried the several different things that were suggested in the thread... It turns out that the one that worked for me was using the external IP address of my machine. So I added a virtual host for "demo" and added it to my hosts file with the external IP address of this machine and everything works great. Weird bug tho!

Frameworks Comparison Presentation Recording

Thanks to everyone who came for the frameworks comparison presentation. We had a lot of folks show up and it seemed to go pretty well. :) For anyone who missed it or would like to share it with friends, you can find the recorded presentation here.

Frameworks Comparison Presentation - Today!

Here's an announcement I probably should have made last week. :)

I'll be giving a presentation on the online ColdFusion meetup at 6pm today covering my Galleon project in which I ported Ray Camden's Galleon forums to several different frameworks (model-glue, mach-ii, 2-flavors of Fusebox and the onTap framework).

More information on the meetup.com site.

I'm somewhat surprised at how popular this presentation is. There were already 10 people RSVPd within 24 hours after Charlie announced it on the meetup calendar. Right now there are 37 RSVPs and nearly as many maybes. So I'm excited. :)

Survey Results Part 2 - What Fusioneers Want (in a framework)

Okay so this isn't the best title ever, but I wanted to spoof the title of the movie What Women Want and this is what I got. :) I think it's appropriate, given the content of this article.

In the film, the main character Nick is a philandering chauvinist who's job as an ad agency executive suddenly changes when his boss, the company's CEO realizes that the company is losing market share to ad agencies who are marketing to a new generation of liberated women. The CEO does what any smart CEO does in that kind of situation - he hires a tough, smart woman to head up the creative department in an effort to save their sinking ship by reinvigorating it with the kind of know-how that will keep them going in a changing market. Now that tough, smart woman, Darcy McGuire is his boss! So Nick does what any smart philandering chauvinist would do: he has a nervous breakdown, gets drunk and accidentally electrocutes himself in the bathtub. When he wakes up, he's able to hear the innermost thoughts of every woman he meets. The horror!... After a brief visit with a psychiatrist however, the panic subsides and he's able to see the advantage in his amazing stroke of luck. Now Nick, who's personal world-view is obviously far from flattering to the average woman, is suddenly able to get a very intimate crash course in all the inns and outs of a woman's world-view. With this new found insight he's able to save his floundering job! Although along the way he chooses to save his soul instead.

My situation may be a bit different than Nick's, but my basic challenge is rather similar. Often in business owners or product managers make the mistake of assuming that they know what everyone wants. Sometimes they do and things work out smashingly, sometimes they don't and the product flops. The smart money is on finding out what people want, so I want to avoid this mistake. But barring a sudden electrical accident in my bathtub and subsequent extrasensory perception, the only way for me to discover what people want is to ask them. I'm not one of these big wall-street businesses, so I can't spend tens of thousands of dollars on focus groups and then bill the American tax payer for the largesse. ;) Instead I have to be more frugal and rely on simpler solutions like direct feedback and free surveys. It's not like I'm in bad company though; Adobe uses frugal surveys to get customer feedback also. So that's what I did. And now I'm sharing those results with the community so everyone can benefit from them.


Survey Results Part 1 - Java, XML and Convention Over Configuration

For the past month or so I've kept all of my open source projects on hold. It's not because I haven't wanted to work on them... I absolutely have. There are several specific tasks that I'm looking forward to completing. I've kept them on hold because Tiffany and I are preparing for a move back to Texas so I can be near my children again and because at the same time I've been dealing with getting some neurological testing (which went exceptionally well), and because I've had some paying client projects (using DataFaucet and the onTap framework) and I wanted to make sure that with the extra things going on at home I would have plenty of time to ensure that these client projects received all the attention they needed.

I find myself in a short lull here and thought this would be a good opportunity to start sharing the information that I've gleaned from the survey I posted in September. Several other framework authors or communities have done the same thing recently, posting surveys to help inform them about how people are using the tools and give them a better handle on fine-tuning their development roadmaps. Adobe has been doing this recently too with an RIA survey they posted to get similar feedback about how people are using Flex and related technologies. This is the first installment in a series of three or maybe five articles sharing my thoughts on some interesting information gathered in our survey.


Limitations of Simplicity?

Okay, yeah, I'm breaking radio silence. :)

There's been a lot going on around here and all my open source projects have been kind of on hold for the past month while these things get taken care of. Tiffany and I are preparing for a move back to Dallas TX so I can be near my kids, so there's been apartment hunting. I've been working on some client work (involving both DataFaucet and the onTap framework). I also got the results of the neurological testing back. The latter indicates that yes I do indeed have Asperger Syndrome, and thankfully nothing else. I feel I'm in good company... perhaps I'll never win a Nobel prize, but I do agree with Vernon Smith that different kinds of minds each have their own advantages. If we all thought the same way, I think it's pretty obvious that we would never progress technologically speaking. There are more things I would like to share regarding autism later, but for now I'm going to get back to ColdFusion.

Over the years I've seen a number of people make comments that they didn't like something or another about ColdFusion because it didn't seem to give them the same kind of control they had with Java. One example of this is with regard to the cfquery tag. I've seen at least one person say that they weren't happy with cfquery because it didn't give them the ability to programmatically control the connection pooling within the application. It worried them that they couldn't get direct programmatic access, that there might be a day when they really needed it and wouldn't be able to get it.

Now I know that this kind of fear isn't entirely unfounded as there are examples of APIs in the wild that were glossy on the outside but that didn't provide access to required low-level functions and forced people to use high-level functions to try and get access to recreate them... This is described as the anti-pattern of abstraction inversion.

So yes, there is such a thing as oversimplification. Which means that these fears aren't entirely unfounded... however... in practice I've never run into "lack of control" as a legitimate barrier when working with ColdFusion.

In over ten years working with CFML I've never run into a scenario in which there was an actual need to programmatically control the database connection pooling. Or for that matter any scenario at all in which CF simply proved to be oversimplified in such a way that there wasn't a viable work around.

Part of the reason for this is that even long before CF was built on top of J2EE, there was relatively easy access to more complicated (lower level) languages like Java and C++. Need to manipulate images programmatically? C++ COM object. Done. The later addition of the cfimage tag is just gravy.

I admittedly would just about rather eat broken glass personally than work with C++ on a daily basis, but my preference isn't really what's in question here. If there's a legitimate business need, we can justify the time for me to figure it out or we can justify the cost of buying a 3rd party API or hiring an outside contractor to make that happen.

At the end of the day, the simplicity of ColdFusion isn't hurting me or the company in any real way that I can tell. As best I can tell the only thing it's doing is helping us meet deadlines.

So where is this mythical oversimplification problem? Does anybody else know? Has anyone else run into problems that were legitimate barriers as a result of ColdFusion being oversimplified? Are there any examples of this on the web?

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress