Copy link to clipboard
Copied
I don't know what else to try. I have created a fully functional ORM CRUD application that is working perfectly when I have the mapping cfc located in the root folder with the index.cfm file that is using it. However, as soon as I move the mapping cfc into the "ORM" folder that is in the root folder and add the cfclocation attribute all I ever get is that it can't find the component or interface. To make sure that it works and I don't have any strange errors I have (in the index.cfm file) instanciated it using createObject with a path of "orm.HistoricalEvents" and then dump it to the screen and that works just fine as well. Below is my setup and directory structure. If anyone has any suggestions i would love to hear them. I love the ORM capabilities and want to use them but I don't want to have a pile of mapping cfcs just sitting in the root folder.
Setup:
Windows 7 Enterprise, 64 bit
IIS 7.5
File Directory/IIS Physical Path: C:\WebDev\DevGamma
Virtual Directory under IIS Default Web Site: /DevGamma
ColdFusion Developer Edition > Standard Installation > All IIS Websites
ColdFusion Directory Location: C:\ColdFusion9
CFIDE Directory Location: C:\inetpub\wwwroot\CFIDE
Folder Structure:
[root]
/orm
HistoricalEvents.cfc
Application.cfc
index.cfm
Application.cfc
component
{
this.name = "CF/1 Application Generator16";
this.version = 1.0;
this.datasource = "fw1testdsn";
this.sessionmanagement = true;
this.ormenabled = true;
this.ormsettings = {
autorebuild="true",
dialect="MicrosoftSQLServer",
dbcreate="update",
cfclocation="orm"
};
}
HistoricalEvents.cfc
component persistent="true" table="HistoricalEvents"
{
property name="EventID" fieldtype="id" ormtype="int" generator="identity";
property name="EventDate" ormtype="date";
property name="EventTitle" ormtype="string" length=250;
property name="EventLocation" ormtype="string" length=50;
property name="EventType" ormtype="string" length=30;
property name="EventRating" ormtype="short";
property name="IsPositiveEvent" ormtype="boolean";
}
index.cfm
<cfset data = EntityToQuery(entityLoad("HistoricalEvents"))>
<cfdump var="#data#">
If anyone needs more information please let me know. If you have any suggestions please send them my way. I want to use ORM but this is killing me and is a deal breaker if I can't get the cfclocation thing to "see" my components. Thanks!
Jason
Copy link to clipboard
Copied
When u invoke cfc just by its name CF automatically scans ur site root, web root and any custom path specified in the CF administrator. So first 2 don't apply since you moved it to a folder, so do yuo have "orm" folder set as custom tag path?
have u tried using qualified path to call your cfc, like "orm.HistoricalEvents" given that the filename for ur cfc is HistoricalEvents.cfc?
Copy link to clipboard
Copied
Both ...
<cfset data = EntityToQuery(entityLoad("orm.HistoricalEvents"))>
and
<cfset data = EntityToQuery(entityLoad("devgamma.orm.HistoricalEvents"))
results in "Mapping for component [whatever path I try] not found"
I also don't have any orm path's mapped anywhere (neither CFX Tags nor ColdFusion Mappings).
Copy link to clipboard
Copied
I haven't had much expirience with ORM but maybe try following:
<cfset data= CreateObject("component", "orm.HistoricalEvents")> <cfset data= EntityToQuery(EntityLoad(data))>
or even map custom tag path to your ORM folder
Copy link to clipboard
Copied
Thanks for the suggestion but that did not work either. I get:
Copy link to clipboard
Copied
Well good news about that it's finding the cfc service.
Try this:
<cfset data= CreateObject("component", "orm.HistoricalEvents")>
<cfset data=EntityLoadByExample(data)>
<cfset data= EntityToQuery(data)>
or
<cfset data= CreateObject("component", "orm.HistoricalEvents")>
<cfset data= EntityToQuery(data)>
Copy link to clipboard
Copied
First suggestion returned error. Second returned empty result set.
I'm not looking for a work around as much as a solution to why ColdFusion can't see my component even when I set up the cfclocation value. I don't like hacks. They tend to cause issues later on especially if the architecture of ColdFusion changes.
Thanks for the suggestions.
Jason
Copy link to clipboard
Copied
I wholeheartedly agree it seems hacky. I had a very similar issue and added the path to the model (mapping cfc) on to my application.cfc's this.customTagPaths list and it suddenly started working.
It seems to me.... that if you specify a cfclocation.... it should..... Just Work. One man's opinion.
See this post where I detail my problem for why I think it can locate the file itself even, but just doesn't know how to handle it: https://groups.google.com/forum/?fromgroups#!topic/coldbox/dFMG5PB6wn4
Copy link to clipboard
Copied
I know that this question is ages old, but did you ever find a solution for this? I tried jingelsthula's recommendation of adding the path to the application.cfc's this.customTagsPath property, but it didn't help. We are using a slightly different environment (Windows 10, CF10), but the description of your issue matches mine exactly.
I'm also eager to use the features of ORM, but have already wasted the majority of a work day trying to figure this issue out.
Thank you.
Copy link to clipboard
Copied
Upon further review - jingelsthula's recommendation did end up being the solution for us. I had not set the customTagsPath value correctly.
I'm providing the following as an example of what we did, just in case it helps someone else.
Folder Structure
[root]
..application.cfc
..index.cfm
..[Models]
....Employees.cfc
Application.cfc (the relevant portion)
component {
...
this.ormenabled = true;
this.datasource = "my_data_source";
//Using customTagPaths INSTEAD of this.ormsettings.cfclocation
this.customTagPaths = "#GetDirectoryFromPath(GetCurrentTemplatePath())#Models";
}
Employees.cfc
component persistent="true" table="tblEmployees" {
}
index.cfm
<cscript>
allEmployees = EntityLoad("Employees");
writeDump(allEmployees); //Now works
</cfscript>
Copy link to clipboard
Copied
Try adding this in your app cfc. Then use them when Creating your CFCs.
You should then be able to use approot.orm.mycfc
Copy link to clipboard
Copied
> cfclocation="orm"
Instead of just orm, I would suggest using the absolute path of the orm directory.