Skip to main content
June 18, 2008
Question

nullpointer exception after page sits for a minute or two

  • June 18, 2008
  • 4 replies
  • 1119 views
I have created a web application which loads the core functionality into application scope as an object. The application.cfc file instantiates the object if it isn't already initialized, and then parses the URL to establish various variables which are utilized to control database queries and layout templates to include.

Everything works fine, but when browsing the site, if a page sits for a minute or two on screen (i.e., I go pour a cup of coffee and return to my computer), then a new link selected, or a page refresh called, the application occasionally throws the java.lang.NullPointerException. The details of the error reveal that the following line is creating the error:

<cfset basicCopy = application.ciCMS.getBasicCopy(#page#)>

Apparently, the variable "page" is somehow expiring, lapsing, disappearing? As I said earlier in this post, within my application.cfc, in the "OnRequestStart" function, I parse the URL to establish a number of variables, including "page". I even set a param for the "page" variable, with a default value, to handle cases where no "page" is passed in the URL.

As I said, this only happens if the page has been sitting for a minute or more (I don't have a precise time frame), and then a new link is selected or page refresh called. After the error displays, another refresh loads the application perfectly, and it continues to function fine until it is left alone for a few minutes.

I can provide more details, including the full error dump, if anyone wants to see it.

My troubleshooting so far: I have introduced cfheader cache-control and expires code to block browser caching, meta tag cache-control, played around with the OnRequestStart function, all to no avail.

Thanks in advance!
This topic has been closed for replies.

4 replies

Participating Frequently
July 2, 2008
No worries. Hope that workaround sorts it out for you.
BKBK
Community Expert
Community Expert
July 2, 2008
Denvermax wrote:
I'm not sure how to address the comments regarding the positioning of the ciCMS object. Does this have anything to do with ColdFusion dropping it's MySQL connection, which is becoming a well-documented bug?

No. However, then, it wasn't yet clear that the culprit could be MySQL. Kronin555's advice about the scope in which to store ciCMS remains good.

... the application works consistently with the exception of this random null error. For the record, we place the ciCMS.cfc object instantiation in the OnRequestStart and check for it's init status before any other processing occurs. If the object is already initialized, we move on, if not, we initialize it. Nothing in the initialization is URL dependent. The placement of the object in the OnRequestStart allows us to re-initialize the application with a URL trigger, rather than having to reset the Application by hand.

Makes things clear.

With "Maintain connections" unchecked, CF is now creating a new connection with each query. You can imagine the performance degradation on high-traffic sites that will result.

Sure thing.



July 2, 2008
BKBK and Kronin555 -

I apologize that I came off as snippy. I've been pounding my head against this null pointer exception for over a week, and my exasperation seeped through. Your advice and troubleshooting efforts were on-target and VERY MUCH APPRECIATED. I have changed the "Maintain connections" option for the datasource in question. This isn't a terribly busy site, so I imagine we'll be fine in terms of server load.

Again, thanks for your help and input. Kronin555, I'm sorry I vented a bit. I hope your solution/sleuthing turns out to be the resolution we were looking for!
BKBK
Community Expert
Community Expert
June 29, 2008
On the subject of MySQL, I made the following suggestion elsewhere. Does it help?

"In the settings page in the Coldfusion Administrator for that particular datasource, choose to Show Advanced Settings. In the Connection String field, enter: autoReconnectForPools=true

Press Submit to register the change."


July 1, 2008
Application uses MySQL 5.

getBasicCopy() in CFC does perform a query.

I'm not sure how to address the comments regarding the positioning of the ciCMS object. Does this have anything to do with ColdFusion dropping it's MySQL connection, which is becoming a well-documented bug? I fail to see how the position of the object in the Application.cfc impacts the issue as I've described it. It is clear (to me, anyway) that the issue is not related to this, since the application works consistently with the exception of this random null error. For the record, we place the ciCMS.cfc object instantiation in the OnRequestStart and check for it's init status before any other processing occurs. If the object is already initialized, we move on, if not, we initialize it. Nothing in the initialization is URL dependent. The placement of the object in the OnRequestStart allows us to re-initialize the application with a URL trigger, rather than having to reset the Application by hand.

BKBK: I will try the "autoReconnectForPools" trick. I would note that this solution won't help those on shared servers who have chosen ColdFusion as their development tool of choice. I saw a post this evening that indicated the latest hotfix to 8.1 may have fixed this problem. I hope so.
Participating Frequently
July 1, 2008
At the bottom of the link I posted:
"FOUND IT! This is what HostMySite eventually said:

The Null Pointer error is due to an issue with ColdFusion8 and MySQL. The fix for this is to uncheck 'Maintain connections across client requests' in the Advanced settings fir the ColdFusion DSN. Please let us know if we can be of further assistance."
BKBK
Community Expert
Community Expert
June 20, 2008
I suspect ciCMS instead. What is it, and what action does it perform on the page variable?

June 28, 2008
Actually, it appears it has nothing to do with my code. It's becoming abundantly clear there's a bug in CF 8.1:

http://forums.crystaltech.com/index.php/topic,33328.0.html

I think when every developer starts experiencing the same error, it's unlikely it's a coding issue.

Adobe??? Hello? Anyone out there? Support your product? Which costs THOUSANDS OF DOLLARS.
Participating Frequently
June 28, 2008
Max,

Is your application using MySQL? Is getBasicCopy() in your CFC doing a query? Did you try this workaround?
http://www.coldfusionjedi.com/forums/messages.cfm?threadid=288E1CA2-19B9-E658-9D557449EC547DF6

What, exactly, does getBasicCopy do?

If cicMS is stored in the APPLICATION scope, why not set it up in OnApplicationStart? It sounds like you instantiate it in the same part of your code where you parse the URL. If that's the case, and it's request-dependent, you shouldn't be storing it in APPLICATION scope. If it's not request dependent, then you should set it in OnApplicationStart and not have to create/instantiate/set it anywhere else.

> I even set a param for the "page" variable, with a default value, to handle cases where no "page" is passed in the URL.

Then it couldn't be page throwing the error.