Reply to topic
Null Pointers exception error. in CFCs
darnold


Joined: 17 Mar 2005
Posts: 22
Reply with quote
I'm having a problem what is a bit hard to explain but I will do my best.

I'm using functions defined in a cfc file to run certain queries. It's an OOP design pattern that I've used for a long time in PHP and this is the first time I've tried to use it in CF. The code works great as long as you don't pause on the site for more than 5 minutes. There is a 5 minutes pause the CFC will drop the variable scopes and deliver a Null Pointers exception error.

From what I can tell it's not picky about what struck or scope gets lost. It appears to have more to do with time. Depending on what page I'm on it might complain about something in the form struck or on another page it complains about an item in the application scope or even the session scope.

One thing is for sure the error is consistent. 5 minutes after the class as been instantiated if no action occurs the next click will result in a null pointer error. If I refresh the page everything goes back to peachy until another 5 minute pause in activity occurs.

In my cfapplication tag I made sure sessionmanagement is on and I set the time out on the application scope to 2 days which is the default at HMS anyway.

This is the easies example to see. Go to http://laweightlosssurgery.com/index2.cfm the page should load fine.

Wait 5 minutes and back to http://laweightlosssurgery.com/index2.cfm to see the error. If you refresh at that point the error goes away.

Anyone see this before or have any idea on fixing it?
darnold


Joined: 17 Mar 2005
Posts: 22
Reply with quote
Looks like this one has got a few people puzzled. I'd like to add my example of the problem on http://laweightlosssurgery.com/index2.cfm was calling the functions with cfinvoke.
I created another copy of the file using one cfobject instead and the result is the same on http://laweightlosssurgery.com/index4.cfm.

Also the problem is not limited to losing variable. It would appear Coldfusion has a temporary glitch and forgets how to process anything in wrapped in pound symbols. These test pages error using
#DateFormat(date,"yyyy-mm-dd")#


I changed that to

Code:
<cfset today = DateFormat(date,"yyyy-mm-dd")>


and the error moved down to where I use
Code:
#today#
nathacof


Joined: 24 Oct 2006
Posts: 93
Location: Bear, DE
Reply with quote
[edit]Shoulda read the post more thoroughly[/edit]
darnold


Joined: 17 Mar 2005
Posts: 22
Reply with quote
Well Now I'm completed confused and rather frustrated. In an effort to just "make it work" I converted everything to using functions without using classes. I figured the problem has to be with the cfc but low and behold the problem still exists and I'm not even using cfcs anymore.

If nothing else I'm finding more ways to get the same error.
bobclingan
Forum Regular

Joined: 16 Sep 2004
Posts: 271
Location: Abingdon, MD
Reply with quote
Could you make your source code available? It may be useful to look at the cfc in question.
darnold


Joined: 17 Mar 2005
Posts: 22
Reply with quote
Sure thing. I got the problem calling any function that uses # pounds signs in the function.
Here is one of them. Also to get the problem the function doesn't need to be in a cfc.

index4.cfm is writtne this way.
instantiate the class:
Code:
<cfobject component="includes.cfcs.index" name="Index_class">


call the function
Code:
<cfset get_events_query = Index_class.get_events()>


display results
Code:
<cfoutput query="get_events_query"> 
                  <hr width="80%" />
                  <p>#title#</p>
                      <p>#timeFormat(time, "h:mm tt")#, #dateFormat(date, "mmmm d, yy")#</p>
                 <p>#location#</p>
                     <cfif (#file# is not "" and FileExists(ExpandPath("./uploads/#file#")))>
                        <cfset link = "<p><a target=""_blank"" href=""uploads/#file#"">Learn More</a></p>">
                     <cfelse>
                        <cfset link = "">
                     </cfif>
                      #link#
                 </cfoutput>


includes/cfcs/index.cfc is written this way
Code:
<cfcomponent>
   <!--- Get upcoming events --->
   <cffunction name="get_events" access="public">
            <cfquery name="getEvents_query" datasource="#application.DSN#" username="#application.USER#" password="#application.PASS#">
               SELECT title,date,time,location,file
               FROM cms_events
               USE INDEX(date)
               WHERE status = 1
               AND date > '#DateFormat(Now(),"yyyy-mm-dd")#'
               ORDER BY date DESC
            </cfquery>

      <cfreturn getEvents_query>
   </cffunction>
</cfcomponent>
Problem Solved!
darnold


Joined: 17 Mar 2005
Posts: 22
Reply with quote
At least as far as I'm concerned it is. I moved the site to another server today and no more error. Happy Day!
Re: Problem Solved!
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 544
Location: Harrisburg, PA
Reply with quote
darnold wrote:
At least as far as I'm concerned it is. I moved the site to another server today and no more error. Happy Day!


Strange..Maybe there was a problem with the CF configuration on the other server. I was contemplating your problem for a while, and couldn't put my finger on it. Glad to hear you have it fixed Cool
Null Pointers exception error. in CFCs
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic