Skip to main content
Inspiring
November 27, 2023
Question

Intermittent : Couldn't find included component

  • November 27, 2023
  • 2 replies
  • 213 views

Hello All,

 

I am facing weird issue with our application, I have included one component using cfinclude tag in one of the cfm file.

Sometimes, my file runs file and includes component successfully but sometimes it gives error "The system cannot find the path specified".

It seems weird issue as sometimes cfinclude works fine and sometimes it doesn't.

 

Please help if anyone have faced the similar issue before or have any comments/advise to give.

Thanks in advance.

    This topic has been closed for replies.

    2 replies

    BKBK
    Community Expert
    Community Expert
    April 7, 2024

    To confirm, what you describe is:

    • page1.cfm includes page2.cfm
    • within page2.cfm, there is code of the form <cfinvoke component="componentName">.

     

    If so, then the situation you describe can result in complications. To solve the problem, ensure the following:

    • the values of the template attribute and component attribute in <cfinclude template="???"> and <cfinvoke component="???">, respectively, are both relative paths. In addition, ensure that each relative path starts from the web root. 
      For example, consider the following scenario in which page1.cfm includes page2.cfm. Within page2.cfm there is a cfinvoke for MyApp.cfc.
      {WEB_ROOT}/workspace/CFProject/testDir1/page1.cfm 
      {WEB_ROOT}/workspace/CFProject/testDir2/page2.cfm 
      {WEB_ROOT}/workspace/CFProject/cfc/MyApp.cfc 

      Then, using relative paths from the root, will result in:
      <!--- code in page1.cfm --->
      <!--- use relative path starting from root  --->
      <cfinclude template="/workspace/CFProject/testDir2/page2.cfm">​
      <!--- code in page2.cfm --->
      <!--- use relative path starting from root  --->
      <cfinvoke component="workspace.CFProject.cfc.MyApp">
    • if access to a file is not 100% certain - for example, a file on a different machine, an uploaded file or a file locked by another process -  then apply fileExists() before any code that uses the file. 
    Charlie Arehart
    Community Expert
    Community Expert
    November 27, 2023

    Why bother with cfinclude of the cfc? It's early morning as I write, but I can't think of any reason it's necessary.

     

    One makes an instance of a CFC available using any of such things as cfobject, createObject, cfinvoke, the new keyword, and so on. Those have both a means of naming the location for a CFC as well as an implicit search path. 

    /Charlie (troubleshooter, carehart. org)
    Inspiring
    November 30, 2023

    Hi @Charlie Arehart ,

     

    Sorry, I wasn't right earlier. We are using cfinvoke only to call the component and not cfinclude.

     

    Thanks,

    Dhanshree

     

    Charlie Arehart
    Community Expert
    Community Expert
    November 30, 2023

    Ok, and yep some have reported that. What specific cf version are you using, and what update? There may be a bug fix that you're missing. 

     

    And are you naming a path before the cfc? What's its value? Does that value refer to a "mapping", and jf so is that defined in the cf admin or the application? And does the path value come from a variable or is it hard coded?

     

    Just saying that any of these things could influence the error, without need of their being a "bug" (as some assert this problem to be). 

    /Charlie (troubleshooter, carehart. org)