Skip navigation
Currently Being Moderated

nullpointer exception after page sits for a minute or two

Jun 18, 2008 9:09 AM

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!
 
Replies
  • Currently Being Moderated
    Jun 20, 2008 10:11 AM   in reply to Max Donnelly
    I suspect ciCMS instead. What is it, and what action does it perform on the page variable?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2008 9:06 AM   in reply to Max Donnelly
    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-19 B9-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.
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2008 11:21 PM   in reply to Max Donnelly
    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."


     
    |
    Mark as:
  • Currently Being Moderated
    Jun 30, 2008 9:26 PM   in reply to BKBK
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 1, 2008 7:49 AM   in reply to denvermax
    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."
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 1, 2008 9:04 AM   in reply to Kronin555
    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.
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 1, 2008 10:59 PM   in reply to Max Donnelly
    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.



     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2008 12:32 PM   in reply to BKBK
    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!
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2008 12:36 PM   in reply to Max Donnelly
    No worries. Hope that workaround sorts it out for you.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points