2

I have a collection of pages, physically rooted at, say, root, with plenty of sub-directories representing applications. Looks like this:

root
 |----a
 |    |-AppA1
 |    |-AppA2
 |
 |----b
      |-AppB2
      |...

I have an IIS server setup to serve root as a virtual directory under the name not_root. I say "not_root" because it can be named anything, so long as it points to root.

My question starts here: I have no mappings at all in my CF setup, but I am able to resolve CFCs stored anywhere in this hierarchy from anywhere in this hierarchy, like so:

new not_root.a.AppA1.someCFC();.

Which I do not fully understand; it appears CF is communicating with IIS about the physical path of the site root, or CF takes the URL into consideration when resolving a CFC?

I am not complaining about this, it is helpful. But I am wondering if someone can point me to a doc or explain how this is working, and if this is expected behavior and can therefore be relied on.

DWR
  • 888
  • 1
  • 8
  • 15
  • Mappings can be set up in code level as well. Can you check in the Application.cfc as well? – rrk May 12 '20 at 22:04
  • there are no explicit mappings; all these application use application.cfm – DWR May 12 '20 at 22:28
  • Look in the CF administrator. My guess is that there’s a mapping that’s defined in your admin settings for “not_root” that points to your root physical directory. It has nothing to do with IIS. – Redtopia May 13 '20 at 00:12
  • If I change IIS's virtual directory name to `not_root2`, I have to go in and change all the names in the instantiation statements to `new not_root2.a.AppA1`, so I'm at a loss to explain this to myself. – DWR May 13 '20 at 12:53
  • I have found that this method of component resolution fails randomly if used in the `extends` attribute of a CFC; it will resolve on each request for some period of time, and then eventually start throwing `NoSuchTemplate` exceptions, requiring a server restart. – DWR Jul 13 '20 at 16:57

1 Answers1

0

Since you have no mappings set it is going to use the webroot relative path, which seems to be what you are describing. The answer to this question might be helpful to understand what is going on:

Mapping to a CFC in ColdFusion

Or here they refer to it as qualified path:

http://dulaw.org/cfdocs/htmldocs/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7e17.html

How you are referencing your CFC's is how we usually did it. The typical settings in the environment did not have any mappings set. A difference was each of our applications had it's own IIS Site with exception of the Dev environments where it was just one IIS Site then apps off that in their own sub-directories. So the Dev environment it certainly been possible for someone to reference a CFC over in AppA1 from AppA2 but it was not something that actually happened.

Snipe656
  • 845
  • 7
  • 15
  • The link provided states: "If you use a cfinvoke or cfobject tag, or the CreateObject function, to access the CFC from a CFML page, ColdFusion searches directories in the following order: a) Local directory of the calling CFML page; b) Web root; c) Directories specified on the Custom Tag Paths page of ColdFusion Administrator" -- I think I am just hung up on the phrase "webroot"; `getPagecontext().getFusionContext().getWebRoot()` returns `C:\inetpub\wwwroot` which is not at all the root of these hierarchies – DWR May 21 '20 at 23:13
  • That is why I liked the first link and word usage of "web-root-relative-path" because when I read something that tells me "web root" I am thinking of an individual IIS Site. I am not thinking about where that "web root" points to in the local file system or on network. So for me a "web root relative path" is going to mean any virtual or real directory off that web root and the CF service is following that "web root relative path" to get to that CFC. – Snipe656 May 23 '20 at 02:10