View comments | RSS feed
Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Using ColdFusion components > Specifying the CFC location PreviousNext

Specifying the CFC location

When you instantiate or invoke a component, you can specify the component name only, or you can specify a qualified path. To specify a qualified path, separate the directory names with periods, not slashes; for example, myApp.cfcs.myComponent specifies the component defined in myApp\cfcs\myComponent.cfc.

ColdFusion uses the following rules to find the specified CFC.

Note: On UNIX and Linux systems, ColdFusion MX attempts to match a CFC name or Custom tag name with a filename as follows: First, it attempts to find a file with the name that is all lowercase. If it fails, it then tries to find a file whose case matches the CFML case. For example, if you specify <cfobject name="myObject" Component="myComponent">, ColdFusion first looks for mycomponent.cfc and, if it doesn't find it, ColdFusion looks for myComponent.cfc.


Contents > Developing ColdFusion MX Applications > Building and Using ColdFusion Components > Using ColdFusion components > Specifying the CFC location PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


enderw88 said on Nov 8, 2003 at 7:31 AM :
Call me silly, but there is something I am missing here. If I don't have any mappings specified in the CF Administrator. Can I still use dot notation to specify the location of a CFC?
jrunrandy said on Nov 10, 2003 at 7:52 AM :
You do not always require mappings to use dot notation in CFCs. If you don't have a cfmapping then you must store the CFC under the webroot or in a custom tag folder.

You still need to use dot notation "folder.folder.cfcname" to tell CFMX which folders to look in.
digitalAnomaly said on Dec 9, 2003 at 9:34 AM :
When macromedia refers to "webroot" are we to assume that webroot refers to ....\apache\htdocs or ...\CFusionMX\wwwroot, or is it any webroot, such as on my virtual host, does webroot refer to the path to the CFC in relation to the root of the site, ie

myResources.components.myComponent
refers to
http://myhost/myResources/components/myComponent

just like in flash? This would be the most appropriate way for anyone developing an application that will be deployed on a hosting companies server. Especially since the extends parameter of a CFC cannot contain a variable (which could be specified dynamically to suit any deployment server).
cf_Amir said on Apr 6, 2004 at 2:05 PM :
How can I have absolute path in my CreateObject("Component", myAbsolutePath) function?

Lets assume I dont have access to ColdFusion Administration page
halL said on Apr 7, 2004 at 6:07 AM :
Response to cf_Amir:
You cannot specify an absolute (or relative) file pathname or URL in CreateObject , cfobject or cfinvoke.
The CFC must be in or under a directory in the search order, and you specify the location in a subdirectory using the dot notation documented on this page.
jim7 said on Apr 12, 2004 at 9:19 PM :
Not being able to specify relative paths is exceedingly inconvenient. Some explanation of the rationale for the CFC location rules would be helpful.
einfo said on May 7, 2004 at 7:09 AM :
Anyone have some clarification on the post from digitalAnomaly about what 'webroot' means in this documentation?
jrunrandy said on May 7, 2004 at 8:07 AM :
I believe that webroot means pretty much the same thing as it does everywhere else in the docs: the top-level directory of pages served by your web server. I think it also includes directories for which you have a web-server mapping and includes virtual hosts, too.
MFI said on May 24, 2004 at 11:56 AM :
The error "Could not find the ColdFusion Component" may occur when trying to use Web root notation. After checking that the path and file names are correct, also check CF mappings. Remove any mappings that are "/" a slash by itself.
wubwub said on Jun 4, 2004 at 1:13 PM :
Ok, here's my situation.

I need to run two versions of the same website on the same machine (slight differences between the pages).

I need the components in site 1 to go to site 1
and the components in site 2 to go to site 2

I can call the components with a global variable:
MM =createObject('component', "#Application.dot_path#.code.data.getdata")

That's easy... now I want to make my getdata.cfc extend another common component

<CFCOMPONENT extends="#Application.dot_path#.code.common">

doesn't work... :-/


I can't put all my components in one directory since I'm looking at over a hundred components so far and that would be far too crowded :-/

I cant use a admin mapping, since the code has to be the same on both sites (except for the demo changes).

Any ideas???
rcollins said on Jun 17, 2004 at 1:34 PM :
wubwub -

In \CFusionMX\wwwroot\WEB-INF\cftags, there's a file named component.cfc which all components implicity extend. You can place any truly "global" component code in there.

http://www.sys-con.com/coldfusion/article.cfm?id=676
rowingpeter_s said on Jun 23, 2004 at 6:39 AM :
I have a CFC under directory called 'domainname.info'. What is the correct syntax for using the hierarchical reference to a cfc under this folder?

eg. cfc is located in c:\inetpub\domainName.info\cfcFolder

I have tried many combinations of quotes and square brackets (something like component = "[domainName.info].cfcFolder.cfcName") but with no success.

Peter
halL said on Jun 24, 2004 at 8:42 AM :
In response to rowingpeter_s.
ColdFusion MX does not support specifying a directory path to invoke a CFC if any directory in the path includes a period in its name.
We have submitted an enhancement request, number 56037, for adding this support.
eapostol said on Jul 6, 2004 at 10:23 AM :
rowingpeter_s said on Jun 23, 2004 at 6:39 AM :

I have a CFC under directory called 'domainname.info'. What is the correct syntax for using the hierarchical reference to a cfc under this folder?

eg. cfc is located in c:\inetpub\domainName.info\cfcFolder

I have tried many combinations of quotes and square brackets (something like component = "[domainName.info].cfcFolder.cfcName") but with no success.

Peter

halL said on Jun 24, 2004 at 8:42 AM :

In response to rowingpeter_s.
ColdFusion MX does not support specifying a directory path to invoke a CFC if any directory in the path includes a period in its name.
We have submitted an enhancement request, number 56037, for adding this support.

In response to the above...Not sure if this is the correct forum, but does this methodology extend to referencing the cf page/component using Actionscript in Flash Remoting? I Have a Flash swf specifying a coldfusion page to return some values, and the production server is set up so that our files are under a directory called domainname.com as well. Our path to the cf page looks like

srv = conn.getService("domainname.com.dev.remoting_study.test_07", this);
// this does not work as it is, since domainname.com is the directory name, and not "domainname" and "com"...
halL said on Jul 12, 2004 at 9:47 AM :
The directory name cannot have a period in it.
This applies to Flash remoting access as well as direct ColdFusion acces.
entact said on Jul 14, 2004 at 4:09 PM :
I'm having related odd issues with CFMX6 on RedHat.7.2

this works
<CFINVOKE COMPONENT="com/intranet/brow"
.....>

this does not
<CFINVOKE COMPONENT="com.intranet.brow"
.....>

no mapping is done and the error is
Could not find the template com.intranet.brow
asterix said on Sep 10, 2004 at 11:08 AM :
With reagrd to using a period (or other special character) in a file directory name:

I also found that an underscore in a directory name will also throw an error -- but I found a work around -- for UNIX systems anyway.

If you create a symbolic link in your system to point to the directory with the special character, and then using the CF administrator to point to that symbolic link, the components can be created.

For example, assume you have a directory:

/myroot//sites_production/

in the /myroot directory, if you create a symbolic link called "production" that points to "sites_production", and then in CF Admin, create a mapping for /myroot/production, you can then create the component.

I image that you can also use Windows Utilities (such as found on www.sysinternals.com) to do something similar on a windows system, although I have not tried this.
No screen name said on Dec 3, 2004 at 8:14 AM :
if my CFC not in the cf_root because the virtual host.
how can i call myservice in the flash remoting?
halL said on Dec 3, 2004 at 11:03 AM :
Flash remoting access to CFCs is limited to locations that are under the web root (not cf_root) for security reasons. Therefore, you can use a virtual directory only if your web server considers it to be under the web root (not the cf_root).
FuseDesign said on Apr 17, 2005 at 7:25 PM :
I am having the exact same issues as "entact" had, but on CFMX 7 and windows.

What happens... (*** all components are called realitivly ***)

1. I am creating an object (with createobject()) that lies in a path above the template.

2. The component I am attempting to create extends another component which is also realitivly located above itself.

3. I get an error stating that the component which is trying to be extended does not exist while using dot notation.

But, if I change the dot notation to "/" it will extend fine.
markg454 said on May 4, 2005 at 2:25 PM :
I am having problems trying to dynamically calculate the CFC component's path. For example, in my Application.cfm, I have defined:

<cfparam name = "Application.CFCRootPath" default="com.pub">

Then I tried to invoke a CFC function as:

<cfinvoke
component="#Application.CFCRootPath#.secure"
method="getuserrole"
returnvariable="authstruct">
<cfinvokeargument name="ContactID" value="#ContactID#">
</cfinvoke>

CFMX6.1 and CFMX7 both throw a "Top level page not found" error.
Nev said on Sep 1, 2005 at 2:11 AM :
RE: Last paragraph Linux CFC's

On a Linux System, does this really mean that a CFC lowerUpperCase naming convention is searched for twice ?

In a typical Mach-ii application involving little logic, this can be up to 800 times.

----------------------------------------------------------------
Note: On UNIX and Linux systems, ColdFusion MX attempts to match a CFC name orCustom tag name with a filename as follows:
First, it attempts to find a file with the name that is all lowercase.
If it fails, it then tries to find a file whose case matches the CFML case.
For example, if you specify <cfobject name="myObject" Component="myComponent">, ColdFusion first looks for mycomponent.cfc and, if it doesn't find it, ColdFusion looks for myComponent.cfc.
----------------------------------------------------------------

Please help
Nev
No screen name said on Sep 6, 2005 at 8:46 AM :
Hello,

I am new to deploying Coldfusion applications on Linux servers and i am having problem making my components work. I have already created a mapping under CFADMIN but it seems that i made a mistake since it still does not work.

Here is a sample scenario of what is happening:
- site webroot
- cms
- component
- dao

I have defined an Application.cfcmapping on my Application.cfc and the current value based on the example would be cms.component.dao.

Now i have created the mapping named /cms on CFADMIN

The physical path of the webroot of the site is:
/virtual/companyname/var/www/sitename

Therefore i defined my mapping as
/cms = /virtual/companyname/var/www/sitename/cms

But this does not work. Coldfusion still says that it cannot find the component.

Btw i am using createobject rather than cfinvoke.

Thanks and regards.

Allan

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/buildi12.htm