Copy link to clipboard
Copied
Hello all:
We have a very strange issue. We have a large CF application that was originally written in CF9, upgraded to CF2016, then onto CF2021. There is a invoicing job that runs as a scheduled task everyday. This invoicing job does many steps (creates, checks, and pays) invoices. There are many components (functions) that are used during this process. We went live with this new server in late November of 2021 and since we have done that, the invoicing job has had issues about 4 or 5 times so far.
The errors I am seeing are usually something like:
Could not find the ColdFusion component or interface components/distributor.distribcontroller.
I say usually, because even the "missing" component changes and they are different each time.
I have checked every component for errors, so that should not be it and most days this invoice job runs fine.
CF2021 is running on Ubuntu 20.04 LTS, 4 CPU.4GB ram. other than this invoice job, application is fine (users never experience missing components)
I also do not use mappings, I have a custom mechanism where I set the compent path in a cfm file and use the "request" structure like: <cfset request.components.distributor = 'components/distributor'> in a file that gets included in the Application.cfc - its may not be ideal, but it is just the was it was build years ago and too much work to change it. (i think).
Any ideas? Any help would be appreciated.
thanks
Artie
Copy link to clipboard
Copied
One word: path. It looks like ColdFusion is expecting to use a dotted path for the component ("components.distributor.distribcontroller"), whereas you are forcing it to use a path with a forward slash ("components/distributor.distribcontroller").
In the move from CF9 to CF2021, there have been some dramatic changes in ColdFusion. Most of them for the better. For example, one consequence is that ColdFusion has generally become stricter. If I were you I would get a fellow CF developer or consultant to review the code.
Copy link to clipboard
Copied
Thank you for your response. I will definately look into your comment. Would what you describe cause the intermittent nature of what we are seeing? Like I mentioned, in the last 60 days this invoice job ran, it failed 4 or 5 times.
Thanks!
Copy link to clipboard
Copied
Would what you describe cause the intermittent nature of what we are seeing? Like I mentioned, in the last 60 days this invoice job ran, it failed 4 or 5 times.
By @artiem51422106
Good question, @artiem51422106 . I honestly can't say for sure. But I shall share with you my thinking.
So my point is not just about slashes vs dots. I am basically attributing the issue to ColdFusion.
But I have to be fair to ColdFusion. In saying what I've said above, I have had to make 2 assumptions:
<!--- /appDir/test.cfm --->
<cfset componentPath=request.components.distributor & ".distribController">
<cfset object=createobject("component",componentPath)>
The following test, however, will result in the kind of error you've been getting:
<!--- CFM test page in a different path relative to Application.cfc --->
<!--- /appDir/subDir/test2.cfm --->
<cfset componentPath=request.components.distributor & ".distribController">
<cfset object=createobject("component",componentPath)>
Copy link to clipboard
Copied
I'm disinclined to think it's about slashes vs dots, for the reason you mention, Artie.
But maybe at the time of the failure, the location that your var resolves to (when cf looks for the cfc) may for some (unexpected) reason not resolve to where it does other times. That WOULD jive with the intermittent nature.
I realize you may think the path is "hard coded" in that var, like in the request.components.distributor, but that search for the cfc gets executed runtime, and different factors could change what it resolves to.
Rather than debate what those COULD BE or even WHY, I'd propose you just wrap the code that fails in a try catch, and in the catch, do a dump/output/log of expandpath(request.components.distributor). When it fails, is it what you'd expect?
Yes, I realize you may have many different places that you any need to check and add this code. (And maybe you already have an error handler, but it would need to know WHAT cfc you were trying to call and the path you were using.)
It's a frustrating challenge, but folks do hit it (the cfc not found). There has to be a solution. I'm not aware that anyone has shared how they resolved it, when we've had this sort of thread...but I could be forgetting. Search for that error, to find other past discussions here or elsewhere.
Copy link to clipboard
Copied
It's a frustrating challenge, but folks do hit it (the cfc not found). There has to be a solution. I'm not aware that anyone has shared how they resolved it, when we've had this sort of thread...
By @Charlie Arehart
Nil desperandum. There's hope. 🙂
@artiem51422106 , you could track down wrong component paths, assuming there are any. To do so, go to the place in Application.cfc where a cfinclude is done. Immediately after the include, add the following debugging code (designed such as not to obstruct the application)
<cffunction name="onRequestStart" returntype="boolean">
<cfargument name = "targetPage" type="String" required="true">
<!--- cfinclude (that sets the component path) goes in here --->
<cfset var templateDir = getDirectoryFromPath(getCurrentTemplatePath())>
<cfset var componentDir = templateDir & request.components.distributor>
<!--- Keep things uniform: replace every backslash with a forward slash --->
<cfset templateDir=replace(templateDir, "\", "/", "all")>
<cfset componentDir=replace(componentDir, "\", "/", "all")>
<cfif NOT directoryExists(componentDir)>
<cflog type="error" file="componentPathNotFound" text="The component path '#componentDir#' does not exist. There was an attempt to use it in a CFM template in '#templateDir#'" >
</cfif>
</cffunction>
As you can see, I have made yet another assumption. Namely, that the include is done in the onRequestStart event-handler.
Copy link to clipboard
Copied
Any chance that changes to the distribcontroller.CFC were published the same time you see errors? I haven't done it with CFCs, but I've seen page not found errors on CFMs if I publish a change to our production environment while users are actively using the system. I think windows removes the existing file before it puts the new file in place.
Another issue I've seen in the past is when our Antivirus software was misconfigured and it was scanning the CF directory. Basically it was blocking CF from accessing the files, but that just caused really long startup times or prevented us from doing file operations.
One other thought, if you've disabled "Component cache" that forces the CF server to resolve the component path on every request. That might explain the intermittent error where 99.9% of the time it manages to resolve it quick enough, but the other 0.1% it doesn't and throws an error about a missing component.
Copy link to clipboard
Copied
Hi @artiem51422106 ,
Is the problem solved? If so, could you share the solution?
If not, have you tried all the suggestions you received?
Copy link to clipboard
Copied
In particular, Artie did you ever try what I had proposed back on the 18th: to have you output the value of expandpath(request.components.distributor), to see if at runtime it may be resolving to a location other than what you presume? It can happen for many reasons. If it does, then once you see the value yo may even connect the dots of what's happening.
If you don't readily solve it with that info, let us know what you find...and also what update level of CF2021 are you on? The update 3 from December? See the CF Admin "settings summary" page to find that info.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now