- The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
- Null Pointers are another name for undefined values.
A co-worker of mine was getting this ColdFusion error message the other day and I was helping him debug the problem. Not knowing anything about his code, the problem was not obvious. I was looking for reference to undefined variables and other more obvious red flags. After dumping out a bunch of variable scopes it seems that all variables existed and had values or empty strings in them.
Since empty string is just a string value, I didn't give it much thought until I then went back to the line that was throwing the error. It was a DateDiff() method call. Then it was obvious. The problem was not that variables and values didn't exist, it was that a ColdFusion DATE/TIME object could not be created based on the variable value.
This is essentially what was causing the error:
- <!--- Set values that are expected to have date/time values. --->
- <cfset dtOne = "" />
- <cfset dtTwo = "" />
- <cfif DateDiff( "d", dtOne, dtTwo)>
- <!--- Ha ha, you get an error. --->
This seems like a very cryptic error. Let's now compare it to one where a non-date object is passed to a function:
- <cffunction name="TestDateValue" returntype="void">
- <!--- Define arguments. --->
- <cfargument name="Value" type="date" required="yes" />
- <!--- Return out. --->
- <cfreturn />
- <!--- Attempty to call the above function with a bunk value. --->
- <cfset TestDateValue( "" ) />
This, of course, throws an error because the value being passed into TestDateValue() is [""] which is NOT a date value. The error is very obvious and self-explanatory:
- The argument VALUE passed to function TestDateValue() is not of type date.
It would be nice if the DateDiff(), DateAdd(), and other such functions could throw similar errors. It makes me curious as to how those functions are working behind the scenes to validate variables.
Looking For A New Job?
- IS Sr. Systems Analyst - Web Development at Nationwide Children's Hospital
- ColdFusion Developers Required at Lions Festivals
- Permanent Senior ColdFusion Developer Wanted at Kelaca
- Experienced ColdFusion Developer Wanted for CFWheels Application at F3G
- Web Applications Developer at Virginia Commonwealth University
I have same problem on my server now.
Here is my problem code. :)
<cfset startdate = CreateODBCDateTime(startdate)>
Have you found any solution?
First of all... great Web site, Ben! I feel like I must be doing the same type of work at my office, because every day I feel like I'm running into these kinds of problems for which you've already posted an explanation.
Anyway, I have a question related to this problem, and I am wondering if you might have a solution...
As you know, ColdFusion's query-of-query functionality has a lot of unexpected behavior. One of them is that the query object must have declared data types on all columns (you actually wrote another posting about this exact point). My problem, of course, is that all of the columns are ending up as VARCHARS, even when they are not.
So, getting to my problem, I am writing a query-of-query in which I am trying to use a CAST function to convert date columns into the DATE data type, so that when I reference them in the Order By clause, they will actually get sorted as dates.
CAST(lastVisited AS DATE) AS lastVisited_DATE
ORDER BY lastVisited_DATE
However, not all columns have dates; some are actually blank. That's where I get the same error message described in your post, because (I believe!) it crashes when trying to convert empty cells to dates.
Do you know of a work-around to this problem?
Thanks for any thoughts you might have!!!
Ben, it's amazing... I think you already helped me. I just saw another blog entry, "ColdFusion Query of Queries and Undefined Cell Values", describing this exact problem, and someone's suggestion to try using the ISNULL function. Thanks... again, great Web site.
Did that work out for you?
I am not a cold fusion expert.. not even close
I know just enough to get myself into trouble...and it seems as if I have.
I am getting the error described above when I go to a particular page directly from my browser
Sometimes the error comes up sometimes not..
* The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
* Null Pointers are another name for undefined values.
(THE ERROR DOES NOT PROVIDE A SPECIFIC LINE OF CODE THAT IS THROWING THE ERROR)
If I refresh the page.. the error does not reappear and I see the actual page everytime.
I just don't know how to debug this error!
Could you tell me what to do to figure out where the issue is? It is very frustrating.
I am on a shared server.
Thank you in advance for any help you might provide!
I've started receiving this type of error on a page for a site I've just recently began developing.
Like Laurence, refreshing the page will get rid of the error and the page will function normally. If left for a few minutes it will cause the error again.
The error occurred in /logic/book.cfm: line 34
32 : FROM book_list, book_list_chapter
33 : WHERE book_list.bookID = book_list_chapter.LINKbook
34 : AND book_list.bookID = '#URL.ID#'
35 : AND book_list_chapter.live = 1
36 : ORDER BY book_list_chapter.chapternumber
This is a new host (moving to it since goDaddy seems opposed to upgrading their coldfusion)
I use logic in the OnRequestStart function of my application.cfc to do a cfparam on all my Querystring variables to set defaults. Which is followed by a conditional to ensure that it is a number 0+.
I've looked through my code and cant find anything that would be allowing the variables to become nulls. Plus all date tags I use are fed from results from my queries, which i know all have proper TS values.
This is a common thing when working with certain environments, particularly dynamic database environments. The same error happened to me, I just stored the information into an array, and then tried to reload the page once again using the same params as the user had previously sent. It worked like a charm.
Is there anyway for you to look at the ColdFusion administrator logs? Or is that all hidden away from you due to the shared nature of your server?
Sometimes, I find that putting a CFFlush at the top of the page (as the very first action of the page request), forces ColdFusion to output a better error message.
Is it possible that you are overriding the "url" value before you run the query?
Application.cfc - OnRequestStart :
<cfparam name="URL.page" default="0">
<cfif NOT isNumeric(URL.page) OR URL.page LT 1>
<cfset URL.page = 0>
and in the page that calls the variable:
<cfquery name="GETchapter" datasource="#application.globvar.DSN#">
WHERE LINKbook = #URL.ID#
AND chapternumber = #URL.page#
AND live = 1
the URL.page are not referenced anywhere else between those code blocks.
In random googling, I found this post on the adobe forums: http://forums.adobe.com/thread/56954?start=0&tstart=0
In which some people say it seems to be an old issue with CF8s mySQL driver.
Your original error output didn't reference the URL.page variable, only the URL.id; can the same be said for URL.id? Are you paramming it? Other than that,I don't have any ideas. Might be a bug in the driver.
Ah yeah, I have 2 queries I use, depending on whether page = 0 or not (0 = ToC)
My first post was a ToC attempt, while this latest post was of a specific page.
The error occurred in /logic/book.cfm: line 7
5 : FROM book_list_chapter
6 : WHERE LINKbook = '#URL.ID#'
7 : AND chapternumber = '#URL.page#'
8 : AND live = 1
9 : </cfquery>
I have noticed this fires during queries to my mySQL DB. I've also noticed that when it does, it seems to always target the last variable use as the error.
Such as on another page:
The error occurred in /logic/books.cfm: line 18
16 : <cfcase value="6">book_list.created, book_list.bookname</cfcase>
17 : <cfcase value="7">book_list.created desc, book_list.bookname</cfcase>
18 : <cfdefaultcase>book_list.bookname</cfdefaultcase>
19 : </cfswitch>
20 : </cfquery>
Which is using a switch statement to determine ORDER BY clause.
And I always param all the QS variables I may use across pages in OnRequestStart.
<cfparam name="URL.ID" default="0">
<cfparam name="URL.act" default="view">
<cfparam name="URL.view" default="list">
<cfparam name="URL.filter" default="0">
<cfparam name="URL.sort" default="0">
<cfparam name="URL.page" default="0">
<cfparam name="URL.tar" default="1">
Another note about this issue, is that when I first load a page, it works, and aslong as I continue using it non stop, it'll work. It's only if I stop using oit for a minute or two, then it will explode, but a refresh fixes it again.
According to that adobe forum, it seems like the Helm control panel probably doesnt have this issue. My host uses Cpanel, and I need to email them to get my CF DSN bound to my DBs.
I Guess this is a matter for my host to look into.
Thanks for your time and advice. Your blog is awesome by the way, been using it for years now
Sorry for dropping out of the conversation; did you get the better of this issue?
I had the same problem with a simple insert statement and all variables were defined. I contacted my hosting site hostmysite.com and they fixed the problem.
Tech Support reply below:
I have unchecked the setting to maintain connections across requests for your DSN in Coldfusion and it has cleared the error you were seeing.
Interesting; sounds like some sort of query-structure caching issue.
First hit on Google for this error and you pointed me in the exact right direction. Thanks, man.
I am getting this error since change the mysql driver from 3 to 4/5.
It happens at random though! I can refresh the page and then it will work fine.
Anyone any ideas? I'd love to give you more information but thats the only error message I get.
Message [empty string]
TagContext Error - array [empty]
Double check the date values in the database. With MySQL, I have found that sometimes moving from a database to another database results in some date/time values becomes zero'd out.
NOTE: I assume you are referring to a line of code that deals with dates as that is what this blog post was about.
Everything on the site has a date in there somewhere, but this error is happening at random, i get the error then i can refresh the page that hasn't changed database-wise or code-wise and the error goes away.
I've only noticed this error occuring since changing mysql driver, another point to note is that the server isnt the most reliable. Can this error occur if the coldfusion service is using too much memory or is unstable?
Hmm, that is odd. When I've had database-related errors, they are typically quite consistent. Sounds like this is gonna a real pain to nail down!
... do you know exactly what line of code is errorring out?
it's on random templates! lol
I think i'm going to have to put it down to this server, perhaps the driver is different from mysql 3.x and returns a row containing null values if it cannot connect to the db, or the db takes longer than it should to bring back the results thus showing the nullpointer error?
I just know that I didnt get this error when using the older mysql driver and I was starting to worry that this error was occuring without me knowing for all my users. It's not a very helpful error message!
Random places! Good luck with that :P In all seriousness, that does sound like a horrible bug to try to iron out. I with I had more advice for you. Did you install the drivers yourself? Or are these the new MySQL 4/5 drivers that came with CF8?
I'm hoping to move the whole thing over to a new server soon.
They are probably the ones that came with cf 8, i'm on a shared platform so the hosting company did it, they aren't coldfusion specialists, in fact i'm not sure what they are specialists in, but lets not go there as it's a whole different story!
Ha ha ha, well good luck with the move.
i'm back again! this error does seem to be more serious than I thought and looks to be related to this post here:
something to do with poor database connection management it seems. I have asked my hosting company to make some of the changes suggest to see if there are any improvements.
Funky stuff! I hope you're able to get it sorted with your hosting company.
I am getting the error
"The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values. "
when trying to execute the following code :
<cfquery name="qry_testDB" datasource="testDSN">
SELECT * FROM myTables WHERE pkID = 1;
Actually my application was running fine in the CF9 developer environment and when I switched to the host server with CF8 such type of error is coming and such error is not coming regularly .Could you please suggest what might be the cause for this error.(I am using MySql DB).
I experienced this Coldfusion error after transferring my server from mysql 4 to mysql 5
I've put together this small article on how to temporarily fix it until a hot fix is released from Adobe:
I hope it helps
<cfapplication name = "sitename" sessionManagement = "yes"
sessionTimeout = "#CreateTimeSpan(0, 5, 0,0 )#" >
THIS is giving me the null pointer error. if i cfabort right after it, it still gives me the error and if i put session mgt to no, it works - but if you put it to yes, boolean yes(1), it fails completely. cf9 - the server hasn't been touched or anything, nor the app file!
Did you solved CFApplicaton Session Management problem?
I got this error yesterday, and it spend me 20hr to try and fix.
I still cannot find a way to fix it, even I re-install coldfusion server.
If any help, I will be profoundly grateful.