• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

nullpointer exception after page sits for a minute or two

Guest
Jun 18, 2008 Jun 18, 2008

Copy link to clipboard

Copied

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!
TOPICS
Advanced techniques

Views

912

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 20, 2008 Jun 20, 2008

Copy link to clipboard

Copied

I suspect ciCMS instead. What is it, and what action does it perform on the page variable?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 28, 2008 Jun 28, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 28, 2008 Jun 28, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 28, 2008 Jun 28, 2008

Copy link to clipboard

Copied

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."


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 30, 2008 Jun 30, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 01, 2008 Jul 01, 2008

Copy link to clipboard

Copied

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."

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2008 Jul 01, 2008

Copy link to clipboard

Copied

As was pointed out in another lengthy thread about resolving this ColdFusion 8 bug by modifying the "Maintain Connections" setting in the CF Administrator:
quote:

I would consider that a temporary workaround, but not a solution. 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. The fact that the error manifests after a lull in activity, and that unchecking "Maintain connections" fixes it, would point to a bug in CF's connection pool handling for MySQL.

(link to that thread)

Not to mention the fact that, again, this precludes solution for those in a shared environment. I know serious CF developers assume everyone has root access to their CF Server, but in reality there are far more sites/applications hosted in a shared environment than are hosted on dedicated servers. Nonetheless, it is helpful to know that the bug can be bypassed in some fashion, until Adobe gets around to resolving it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2008 Jul 01, 2008

Copy link to clipboard

Copied

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.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 02, 2008 Jul 02, 2008

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 02, 2008 Jul 02, 2008

Copy link to clipboard

Copied

LATEST
No worries. Hope that workaround sorts it out for you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation