Cold fusion errors - null null, The error occurred on line -1., and java.lang.NullPointerException

Error: null null The error occurred on line -1.

Stack Trace: java.lang.NullPointerException

I have come across these errors in the past and every single one of them is a result of a date function going awry.

One example is a client of mine using a drop down box to "create" a date. They would have a drop down for the month, a drop down for the day (31 days), then one for the year. On the action page, this line of code exists:

#CreateODBCDate(CreateDate(FORM.Year2,FORM.Month2,FORM.Day2))#

So whenever a user would submit an invalid date (04/31/07, 5/d/07, etc.), This line would produce a "null null" error. Cold Fusion has awesome error descriptions, so a description of "null null" leaves you scratching your head. The above error is handled by using simple error catching javascript on the form page and/or a line of server side code on the action page:

<cfif NOT isDate("#Form.Month#-#Form.Day#-#Form.Year#")>
<!--- This is not a date so do something --->
</cfif>

Of course, client side error handling should have been implemented on the form page originally. Try not to forget about CFFORM and Javascript! I implemented some quick and easy client-side error handling, and this page is sitting pretty.

I have come across this error multiple times, and it has always been a date issue. If you're getting a similar error, review those dates!

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Mark Lewis's Gravatar Thanks David, I couldn't figure out why I was getting this error, until I realised after abouts 4hours of changing my code that there arent 31 days in September :-s
# Posted By Mark Lewis | 10/2/07 4:28 AM
# Posted By mgwalk | 3/25/08 12:43 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.