title: The symbol you provided is not a function
body: <hr>
  
  <p><strong>Key points before reading further</strong></p>
  
  <ol>
  <li>All variables are properly var'ed (you'll have to trust me)</li>
  <li>Scopes <em>are not</em> being reset while these long-running processes are happening</li>
  <li>When dumping the metadata for the supposedly missing/invalid method, I get the right information </li>
  <li>There are only two places where the name of this method are referenced in the application. Once where it's defined, and once were the method is called in the code below.</li>
  </ol>
  
  <hr>
  
  <p>I have a very strange intermittent error that I can't seem to track down. Here's the background (these are severely trimmed down to simplify for posting).</p>
  
  <p>FeedService.cfc:</p>
  
  <pre><code>&lt;cfcomponent output="false" extends="FeedDAO"&gt;
  
      &lt;cffunction name="processXmlFile" access="public" output="false" returntype="struct"&gt;
          &lt;cfset Var local = StructNew() /&gt;
  
  /***************************************
  THE VARIABLES ARE ALL VAR'D - PROMISE!!!
  Lots of other stuff goes on in here to get the ultimate set of XML nodes to loop through
  *****************************************/
  
          &lt;cfloop from="1" to="#ArrayLen(local.arrChannels)#" index="local.currentChannelItem"&gt;
              ... Lots of XML parsing and stuff and things going on here ...
  
              &lt;cfset LOCAL.invCheck = checkCustomerListing(
                  Acct_ID = local.invStruct.AcctID
                  , CustomerListingID = local.invStruct.CustomerListingID
              ) /&gt;
  
              ... Lots more stuff going on here ...
  
          &lt;/cfloop&gt;
      &lt;/cffunction&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p>FeedDAO:</p>
  
  <pre><code>&lt;cfcomponent output="false"&gt;
  
      &lt;cffunction name="checkCustomerListing" access="public" output="false" returntype="numeric" hint="Returns the numeric inventory ID for an existing inventory listing, or 0 if the listing doesn't exist."&gt;
          &lt;cfargument name="Acct_ID" type="numeric" required="true" hint="" /&gt;
          &lt;cfargument name="CustomerListingID" type="string" required="true" hint="" /&gt;
          &lt;cfset var rs = ""&gt;
  
          &lt;cfquery name="rs" datasource="#Variables.DSNs.Primary#"&gt;
              SELECT ID FROM TheTable
              WHERE
                  Acct_ID = &lt;cfqueryparam cfsqltype="cf_sql_integer" value="#Arguments.Acct_ID#" /&gt;
                  AND Customer_Listing_ID = &lt;cfqueryparam cfsqltype="cf_sql_varchar" value="#Arguments.CustomerListingID#" /&gt;
          &lt;/cfquery&gt;
  
          &lt;cfif rs.RecordCount&gt;
              &lt;cfreturn rs.Inv_ID /&gt;
          &lt;cfelse&gt;
              &lt;cfreturn 0 /&gt;
          &lt;/cfif&gt;
  
      &lt;/cffunction&gt;
  
  &lt;/cfcomponent&gt;  
  </code></pre>
  
  <p>I'm calling the initial function like so:</p>
  
  <pre><code>&lt;cfset processStruct = Server.FeedService.processXmlFile(filePath) /&gt;
  </code></pre>
  
  <p>So, when a feed gets submitted to the processXMLFile function, it looks through all of the items in the file. A feed file may have 10, 100, or even 1000 entries. I get occasional error messages like this while a file is getting processed:</p>
  
  <pre><code>[struct]
  Detail: The symbol you provided checkCustomerListing is not the name of a function.
  Message: Entity has incorrect type for being called as a function.
  StackTrace: coldfusion.runtime.CfJspPage$UninvocableEntityException: Entity has incorrect type for being called as a function.
      at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2441)
      at coldfusion.runtime.SuperScope.invoke(SuperScope.java:18)
      at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2222)
  </code></pre>
  
  <p>More stack dump information</p>
  
  <pre><code>    Type: Application
      symbolName: checkCustomerListing
  
      [object of coldfusion.runtime.CfJspPage$UninvocableEntityException]
      Class Name: coldfusion.runtime.CfJspPage$UninvocableEntityException
      Fields: 
          java.lang.String symbolName: checkCustomerListing
      Parent Class: [object of coldfusion.runtime.ApplicationException]
          Class Name: coldfusion.runtime.ApplicationException
          Parent Class: [object of coldfusion.runtime.NeoException]
              Class Name: coldfusion.runtime.NeoException
              Methods:  
                  findAdvancedCFTarget(coldfusion.runtime.AdvancedCFException, java.lang.String[]) returns int 
                  findCustomTarget(coldfusion.runtime.CustomException, java.lang.String[]) returns int 
                  findThrowableTarget(java.lang.Throwable, java.lang.String[]) returns int 
                  getDetail() returns java.lang.String 
                  getLocalizedMessage() returns java.lang.String 
                  getMessage() returns java.lang.String 
                  getRootCause() returns java.lang.Throwable 
                  getString(java.lang.Throwable, java.lang.String, java.util.Locale) returns java.lang.String 
                  getType() returns java.lang.String 
                  setLocale(java.util.Locale) returns void 
                  unwrap(java.lang.Throwable) returns java.lang.Throwable
              Parent Class: [object of java.lang.RuntimeException]
                  Class Name: java.lang.RuntimeException
                  Parent Class: [object of java.lang.Exception]
                      Class Name: java.lang.Exception
                      Parent Class: [object of java.lang.Throwable]
                          Class Name: java.lang.Throwable
                          Methods:  
                              fillInStackTrace() returns java.lang.Throwable 
                              getCause() returns java.lang.Throwable 
                              getLocalizedMessage() returns java.lang.String 
                              getMessage() returns java.lang.String 
                              getStackTrace() returns java.lang.StackTraceElement[] 
                              initCause(java.lang.Throwable) returns java.lang.Throwable 
                              printStackTrace(java.io.PrintWriter) returns void 
                              printStackTrace(java.io.PrintStream) returns void 
                              printStackTrace() returns void 
                              setStackTrace(java.lang.StackTraceElement[]) returns void 
                              toString() returns java.lang.String
  </code></pre>
  
  <p>I may get one error in 1000 entries, or I may get a small batch of errors at one time, and the rest of the feed processes just fine (due to some try/catch logic to prevent the entire thing from crapping out). At one point, the <code>checkCustomerListing</code> was in a completely different Server scoped object, and I never had a problem. I moved it into the <code>FeedDAO</code> and started calling it via the Super scope, and that's when these intermittent errors began.</p>
  
  <p><em>UPDATE</em>: I have everything properly var'ed, I just chopped it all out for the sake of brevity. </p>
  
  <p><em>UPDATE AGAIN</em>: Changed code sample comments to make it clear that there is <em>a lot</em> of stuff going on before the first loop begins, including setting all LOCAL variables that will be used in the loop.</p>
  
  <p><em>More Code Information</em>:
  I should note that there are only two places in our entire application (thousands upon thousands of lines of code) where the string 'checkCustomerListing' exists. One is where the function is called, and two is where the function is declared. There are no other instances of the string <code>checkCustomerListing</code> anywhere.</p>
  
  <p><strong>Update: 6 September, 2011</strong></p>
  
  <p>I added some additional error checking to see if I could find out what the app thought <code>checkCustomerListing</code> was (thanks Adam and Ryan). Here's my new try/catch statement:</p>
  
  <pre><code>&lt;cfcatch type="any"&gt;
      &lt;cfset local.tmpError.cfcatch = cfcatch&gt;
  
      &lt;cfif isDefined("checkCustomerListing")&gt;
          &lt;cfset local.tmpError.customerListing = checkCustomerListing /&gt;
          &lt;cfset local.tmpError.customerListingMeta = getMetaData(checkCustomerListing) /&gt;
      &lt;cfelse&gt;
          &lt;cfset local.tmpError.customerListing = "Checkcustomerlisting is not defined" /&gt;
      &lt;/cfif&gt;
  
      &lt;cfset Server.Utilities.Errors.emailCaughtError(local.tmpError)&gt;
  
  &lt;/cfcatch&gt;
  </code></pre>
  
  <p>So I got an error this morning, and in the email I received, there is no <code>customerListing</code> node in the dump, but there is a meta node:</p>
  
  <pre><code>CUSTOMERLISTINGMETA:  
      [struct]
      ACCESS: public
      HINT: Returns the numeric inventory ID for an existing inventory listing, or 0 if the listing doesn't exist.
      NAME: checkCustomerListing
      OUTPUT: false
      PARAMETERS:  
          [array]
          1) [struct]
              HINT: [empty string]
              NAME: Acct_ID
              REQUIRED: true
              TYPE: numeric 
          2) [struct]
              HINT: [empty string]
              NAME: CustomerListingID
              REQUIRED: true
              TYPE: string 
      RETURNTYPE: numeric
  </code></pre>
  
  <p>All of that meta information is <em>exactly</em> correct... so if it can find the metadata for the function, why can't it find the function itself?</p>