Solve the "Could not find the ColdFusion Component" issue
I'm sure someone has posted this before but for my own reference (or anyone who doesn't know)!
If you want to be able to create a CFC from a template that needs you to navigate up the directory tree then you can't because of the dot notation that ColdFusion uses. You'll probably see an error like
Could not find the ColdFusion Component or Interface path.to.cfc.
Ensure that the name is correct and that the component or interface exists.
Or
The ../path.to.cfc name is not a valid component or interface name.
Component and interface names cannot be empty and cannot start or end with a period.
The way to solve this is to create your own function in Application.cfc which will look something like this:
<cffunction name="CreateCFC" returntype="any">
<cfargument name="path" required="true" />
<cfscript>
Return CreateObject('component', Arguments.path);
</cfscript>
</cffunction>
So, now all you need to do when you want to create a CFC, instead of doing:
CreateObject('component', 'path.to.my.cfc');
You can do this from anywhere inside your web application (by which I mean anywhere at the same level or below your Application.cfc):
CreateCFC('path.to.my.cfc');
A simple solution to an annoying problem!
UPDATE: ColdFusion 8 has been released since I wrote this post and it has a feature calling per application mapping which is incredible useful. I've got a post about it here: Per-Application Mappings
- Posted in:
- ColdFusion


You've essentially made an application scoped factory. In and of itself, this isn't a bad thing. If you are going to write CFC based applications of complexity, it might be a good idea to look into ColdSpring or LightWire.
Both are factories and also provide Dependancy Injection capabilities which are very helpful in keeping your code clean and your dependancies in line.
Hope this helps.
DW
Comment by Dan Wilson – April 24, 2008
Comment by Arun – August 07, 2009
I usually just add add the path into the compiler arguments when I start a new Flex project. Sometimes however, I end up needing to re-creating my Flex project instance and I often forget to add the config setting back until I see the error. Just thought I would bring this up.
Project -> Properties -> Flex Compiler -> Additional Compiler Arguments:
-locale en_US -services "C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\flex\services-config.xml"
Comment by molaro – January 25, 2010
I have a cfc inside a path below mac/framework/listenermanager.cfc
where MAC and FrameWork are the folders.
I need to access a cfc in path below
calender/listeners/calendarlistener.cfc
Where Calender and Listeners are the folders
Mac and calendar share the same folder level.
When i try to create a object for the cfc and try to access the caledarlistener.cfc i get the following error.
'Could not find the ColdFusion Component or Interface path.to.cfc.Ensure that the name is correct and that the component or interface exists.'
The code i have used to create object:
<cfset listener = CreateObject('Component',calender.listener.calendarlistener.cfc)
Please let me know how to solve this issue.Any mappings required in administrator level.
Comment by Lakshmi – August 16, 2010
You can use per-application mappings which I find really useful if you're not running off the webroot.
Comment by John Whish – August 17, 2010
<cfset listener = CreateObject('Component',calender.listener.calendarlistener')>
and also ensure that the path is correct - as @JohnWhish said - your code has listener, but your description above it says the folder is listeners.
Comment by Adrian Thomson – September 08, 2010
I am struck with another issue.I have a folder structure say 'Apple' inside 'Apple' i have folders as 'bat' and 'cat'.Inside bat i have cfc called dog.cfc.Inside cat i have fan.cfc.I wanted to access dog.cfc from fan.cfc.
Apple\bat\dog.cfc
Apple\cat\fan.cfc
kindly help.
Comment by Lakshmi – September 08, 2010
CreateObject("component", "Apple.bat.dog")
from inside Apple\cat\fan.cfc and it will find the cfc. If you're on ColdFusion 8 or higher, you might want to read a newer post I wrote about per-application mappings:
www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/per-application-mappings-253
Comment by John Whish – September 08, 2010