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
3 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