我在浏览器中无法复制的日志中遇到问题。我每天获得数百个这样的数字无效的组件定义
invalid component definition, can't find component [cfc.udf]
cfc存储在应用程序上一级的cfc文件夹中。这使得许多应用程序可以使用相同的cfc。
文件夹结构:
---- cfc
--------- udf.cfc
---- myApp
--------- application.cfc
在的Application.cfc,我使用的是专用的映射,因为这是在生产中有很多不同的负载平衡服务器的设置,以及一个QA环境和当地的测试环境并保持全部同步将是困难的。
在onRequestStart,我有一个函数,每5分钟重新启动应用程序。它由顾问提供。我怀疑这是罪魁祸首,因为日志显示这些错误来在整整5分钟的间隔
<cfcomponent>
<cfset This.name = "myApp">
<cfset This.Sessionmanagement=true>
<cfset This.Sessiontimeout="#createtimespan(0,0,30,0)#">
<cfset this.mappings['/cfc'] = ExpandPath('../cfc')>
<cffunction name="onApplicationStart">
<cfset Application.udf = createObject("component", "cfc.udf").init()>
</cffunction>
<cffunction name="onRequestStart">
<cfset appRefreshMinutes = 5>
<cfif Not IsDefined("Application.refreshTime")>
<cfset currentMinute = Minute(Now())>
<cfset Application.refreshTime = DateAdd("n", -(currentMinute MOD appRefreshMinutes)+appRefreshMinutes, Now())>
<cfset Application.refreshTime = DateAdd("s", -(Second(Application.refreshTime)), Application.refreshTime)>
</cfif>
<cfif Now() GTE Application.refreshTime Or IsDefined("URL.reload")>
<cflock name="ApplicationInit" type="exclusive" timeout="5" throwontimeout="false">
<cfif Now() GTE Application.refreshTime Or IsDefined("URL.reload")>
<cfset OnApplicationStart()>
<cfset Application.refreshTime = DateAdd("n", appRefreshMinutes, Application.refreshTime)>
</cfif>
</cflock>
</cfif>
</cffunction>
</cfcomponent>
您是否尝试过使用映射名称而不是'/ cfc'?像''cfset this.mappings ['/ somethingelse'] = ExpandPath('../ cfc')>',这样你就可以像调用它一样'。也许它看起来很奇怪... –
我继续并测试更改映射名称。现在我必须等待,看看它是否会再次发生,因为我无法复制它 –
@ Miguel-F:你说得对,它是导致问题的映射的名称。请提交它作为答案,以便我可以接受它作为正确的答案 –