NPEs, onRequest, and other mysteries of the universe...

A friend wrote to me this morning with an interesting problem. He recently moved his site (hosted at CrystalTech) from ColdFusion 7 to ColdFusion 8. Then he began to get NPEs (Null Pointer Exceptions) in regards to cfquery tags. He would get these about once per 1-2k hits.

But get this - CystalTech recommended adding a blank onRequest:

<cffunction name = “onRequest” access = “public” returnType = “boolean” output=”true”>

<cfargument name = “thePage” type = “string” required = “true”>

<cfinclude template=”#arguments.thePage#”>

<cfreturn true />

</cffunction> </code>

And it worked! He no longer got the NPE error. Now I don’t know about you - but I can’t imagine any reason why this change would make his error go away. Can anyone else think of a reason why it would help?

As for the NPE in general - one thing I’ve asked him if is the cfquery was in a CFC and he possibly forgot to var scope. Not that I think it would make a NPE, but the lack of var scoping is something that could lead to random errors like he observed.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless 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

Comments