Solve the "Could not find the ColdFusion Component" issue
April 24, 2008
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!
- Posted in:
- ColdFusion
5 comments
Leave a comment
If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)





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