【发布时间】:2011-09-14 20:54:16
【问题描述】:
进一步阅读之前的要点
- 所有变量均已正确更改(您必须相信我)
- 作用域不会在这些长时间运行的进程发生时被重置
- 在为所谓的缺失/无效方法转储元数据时,我得到了正确的信息
- 在应用程序中只有两个地方引用了此方法的名称。一次是在哪里定义的,一次是在下面的代码中调用该方法。
我有一个非常奇怪的间歇性错误,我似乎无法追踪。这是背景(为了简化发布,这些都被严重删减了)。
FeedService.cfc:
<cfcomponent output="false" extends="FeedDAO">
<cffunction name="processXmlFile" access="public" output="false" returntype="struct">
<cfset Var local = StructNew() />
/***************************************
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
*****************************************/
<cfloop from="1" to="#ArrayLen(local.arrChannels)#" index="local.currentChannelItem">
... Lots of XML parsing and stuff and things going on here ...
<cfset LOCAL.invCheck = checkCustomerListing(
Acct_ID = local.invStruct.AcctID
, CustomerListingID = local.invStruct.CustomerListingID
) />
... Lots more stuff going on here ...
</cfloop>
</cffunction>
</cfcomponent>
FeedDAO:
<cfcomponent output="false">
<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.">
<cfargument name="Acct_ID" type="numeric" required="true" hint="" />
<cfargument name="CustomerListingID" type="string" required="true" hint="" />
<cfset var rs = "">
<cfquery name="rs" datasource="#Variables.DSNs.Primary#">
SELECT ID FROM TheTable
WHERE
Acct_ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#Arguments.Acct_ID#" />
AND Customer_Listing_ID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#Arguments.CustomerListingID#" />
</cfquery>
<cfif rs.RecordCount>
<cfreturn rs.Inv_ID />
<cfelse>
<cfreturn 0 />
</cfif>
</cffunction>
</cfcomponent>
我这样调用初始函数:
<cfset processStruct = Server.FeedService.processXmlFile(filePath) />
因此,当提要提交给 processXMLFile 函数时,它会查看文件中的所有项目。一个提要文件可能有 10、100 甚至 1000 个条目。在处理文件时,我偶尔会收到类似的错误消息:
[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)
更多堆栈转储信息
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
我可能会在 1000 个条目中遇到一个错误,或者我可能会一次收到一小批错误,而其余的提要处理都很好(由于一些 try/catch 逻辑可以防止整个事情搞砸)。在某一时刻,checkCustomerListing 在一个完全不同的服务器范围对象中,我从来没有遇到过问题。我将它移到 FeedDAO 并开始通过 Super 范围调用它,这就是这些间歇性错误开始的时候。
更新:我已经正确地修改了所有内容,为了简洁起见,我只是将其全部删除。
再次更新:更改了代码示例 cmets,以明确在第一个循环开始之前有很多内容正在进行,包括设置所有 LOCAL 变量在循环中使用。
更多代码信息:
我应该注意到,在我们的整个应用程序中(成千上万行代码)中只有两个地方存在字符串“checkCustomerListing”。一是调用函数的地方,二是声明函数的地方。在任何地方都没有字符串 checkCustomerListing 的其他实例。
更新:2011 年 9 月 6 日
我添加了一些额外的错误检查,看看我是否可以找出应用程序认为 checkCustomerListing 是什么(感谢 Adam 和 Ryan)。这是我的新 try/catch 语句:
<cfcatch type="any">
<cfset local.tmpError.cfcatch = cfcatch>
<cfif isDefined("checkCustomerListing")>
<cfset local.tmpError.customerListing = checkCustomerListing />
<cfset local.tmpError.customerListingMeta = getMetaData(checkCustomerListing) />
<cfelse>
<cfset local.tmpError.customerListing = "Checkcustomerlisting is not defined" />
</cfif>
<cfset Server.Utilities.Errors.emailCaughtError(local.tmpError)>
</cfcatch>
所以今天早上报错了,在我收到的邮件中,转储中没有customerListing节点,但是有一个元节点:
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
所有元信息完全正确正确......所以如果它可以找到函数的元数据,为什么它不能找到函数本身?
【问题讨论】:
-
我不知道这是否是您帖子缩减的一部分,但 local.arrChannels 是在哪里声明的?
-
您能告诉我们您正在运行什么版本的 ColdFusion。一些 cmets 指的是 varring,但如果您运行的是 ColdFusion 9,那么 local 是一个有效范围,不需要任何范围。
-
James,这个问题已经被标记为“coldfusion-8”,这应该可以为 Dan 使用的版本提供一个小线索。 ;)
-
通过函数开头的 XML 解析。唯一的问题是它认为函数不存在。如果我有未声明的变量,它甚至永远不会归结为问题部分。
-
您是否尝试过在错误处理中的某处对 checkCustomerListing 进行转储,以便在抛出错误时准确查看 checkCustomerListing 是什么?听起来肯定有什么东西正在影响指向该函数的变量中的东西。