Hire Me! I'm currently looking for my next role in developer relations and advocacy. If you've got an open role and think I'd be a fit, please reach out. You can also find me on LinkedIn.

This question came in this morning. Looking at the code below, see if you can determine the issue. (Of course, the title of the blog entry is a bit of a give away.)

<cffunction name="onRequestStart" returntype="boolean" access="public"> <cfargument name="url" required="true" type="string"> <cfif StructKeyExists(url, "init")> <cfset onSessionStart()> </cfif> <cfreturn true> </cffunction>

This is a fairly simple onRequestStart - and one based on a pattern I use quite a bit - specifically the init URL hook to restart something (normally the Application, but in this case the Session). When run, this gives the following error:

You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.

So what's the issue? By accident, the user named the argument to onRequestStart the same as one of ColdFusion's built-in scopes. By telling ColdFusion to pass the requested page as "url", it blew away the URL scope. Instead of a structure, URL was now a simple string.

Easy enough mistake to make - and I swear I looked at it for five minutes before I noticed it.