Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Intermitten CFC not found - Coldfusion 2021 Standard.

New Here ,
Jan 18, 2022 Jan 18, 2022

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

 

606
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2022 Jan 18, 2022

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2022 Jan 18, 2022

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!

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2022 Jan 19, 2022

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.

 

  • By default, ColdFusion will either use dots, backward slashes or forward slashes for component paths, but not a combination of dots and slashes. So, if ColdFusion defaulted to a component path, that path might be different from the one generated using your setting. May ColdFusion identify the paths  "components.distributor.distribcontroller" and "components/distributor/distribcontroller", but fail to identify "components/distributor.distribcontroller"? That is unlikely, but possible.
    I wonder whether caching (of paths or component objects) plays a part in this.
  • Mappings aren't used in your application. They are ColdFusion's sure-fire way to map component paths with some measure of permanence. When you supply paths manually instead, you then cannot be 100% sure. That has been my experience with ColdFusion.
    Again, I wonder whether caching plays a part in this.

 

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:

 

  1.  The CFC files concerned are physically on the server. (As opposed to apps that write CFCs to the file system). Let's say /appDir/ is the directory containing Application.cfc. Then the path to the file distribcontroller.cfc is /appDir/components/distributor/distribcontroller.cfc
  2. /appDir/ is the location of the CFM file in which you instantiate the component. That is
    <!--- /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)>

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2022 Jan 18, 2022

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. 


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2022 Jan 19, 2022

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 19, 2022 Jan 19, 2022

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 30, 2022 Jan 30, 2022

Hi @artiem51422106 ,

Is the problem solved? If so, could you share the solution?

If not, have you tried all the suggestions you received?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 30, 2022 Jan 30, 2022
LATEST

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.


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources