3

I'm having an issue in the logs I cannot replicate on the browser. I'm getting hundreds of these per day

invalid component definition, can't find component [cfc.udf]

The cfc are stored in a cfc folder one level above the app. This is so that many apps can use the same cfc.

Folder structure:

---- cfc
--------- udf.cfc
---- myApp
--------- application.cfc

In the application.cfc, I'm using application-specific mappings because this is set on a lot of different load-balanced-servers in production as well as a QA environment and local testing environment and keeping them all synced would be difficult.

At onRequestStart, I have a function that restarts the application every 5 minutes. It was supplied by a consultant. I suspect that this is the culprit because the logs show these errors coming in at exactly 5 minute intervals

<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>
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Jack Pilowsky
  • 2,275
  • 5
  • 28
  • 38
  • Have you tried using a mapping name other than `/cfc`? Like `` so that you can then call it like ``. Maybe it just looks odd... – Miguel-F Mar 02 '16 at 20:30
  • I went ahead and tested changing the mapping name. Now I gotta wait to see if it will happen again as I cannot replicate it – Jack Pilowsky Mar 02 '16 at 21:30
  • @Miguel-F: You were right it was the name of the mapping that was causing the issue. Please submit it as an answer so I can accept it as the correct answer – Jack Pilowsky Mar 02 '16 at 21:52
  • Will do. Glad it solved your issue. – Miguel-F Mar 03 '16 at 13:24
  • Check this post that may resolve your issue: [link](http://stackoverflow.com/questions/6875621/railo-application-cfc-this-mappings-not-working) – Viv Mar 03 '16 at 18:05

1 Answers1

2

Promoted from the comments

Have you tried using a mapping name other than /cfc? Like:

<cfset this.mappings['/somethingelse'] = ExpandPath('../cfc')>

so that you can then call it like:

<cfset Application.udf = createObject("component", "somethingelse.udf").init()>

Maybe it just looks odd to me or maybe that is causing your issue (cfc being a reserved word or somehow getting special treatment in this case).

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
  • Miguel-F, sorry, I was wrong. This is not the issue. I thought it was because I stopped getting the error messages but the reason that I stopped getting the errors was because I screwed up and sent a copy of the application.cfc with a cfabort inside that onrequeststart method. Oops. 20 minutes later I got an angry call from the client. Now, I'm getting invalid component definition, can't find component [somethingelse.udf]. I'm going to try putting a cfdump of the application on the error logs. – Jack Pilowsky Mar 03 '16 at 17:21
  • Well sorry about that. Please post your solution to avoid any confusion. – Miguel-F Mar 03 '16 at 18:20