CF10 Incorrect component mapping on EntitySave

50 views
Skip to first unread message

Spencer Neff

unread,
Jun 21, 2016, 3:54:59 PM6/21/16
to cf-orm-dev
We have a CF10 app using FW/1 framework. I am hitting an ORM problem on my Linux development machine that we can't replicate on my boss's Windows machine. Now he is threatening to force me to develop on Windows! Please help :)

When we create a new Event entity, our EventService.cfc calls EntityNew("Event"), sets some properties and relations, and successfully executes EntitySave. After persisting the Event, our createEvent function attempts to create a new EventQuestionLink entity:

var newLink = EntityNew("EventQuestionLink",{...});
EntitySave(newLink);

The app crashes with "Mapping for component model.ORM.EventQuestionLink not found. But this component name is incorrect, it should be com.model.ORM.EventQuestionLink.

If I create various other new entities and dump them on a test page, they have the correct component names com.model.ORM.EntityName. But when I create a new EventQuestionLink entity, its name is missing the leading "com".

I don't even know where to look next, so I hope you can give me some advice. Thanks in advance.

Cameron Childress

unread,
Jun 21, 2016, 4:06:10 PM6/21/16
to cf-or...@googlegroups.com
A few things to try:

1) Did you specify the FULL entity name in the conponent definition?
<cfcomponent entityName = 'com.model.ORM.EventQuestionLink' />

2) Does it work if you start to specify the long version of the Entity? Don't allow the engine to guess on it's own. This means using the long format in component definitions, return types, and in entity() methods...
ie: EntityNew("com.model.ORM.Event")

3) Check the case on EVERYTHING. make sure you are capitalizing the filesnames for all entities and folder names consistently and that they match the actual filenames.

4) I would personal avoid using words that are potential "reserved words". In your situation that would include a directory called "ORM" and a CFC named "Event". This is probably not your problem but I have learned the very hard way just to avoid that at all costs.

-Cameron



--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cf-orm-dev+...@googlegroups.com.
To post to this group, send email to cf-or...@googlegroups.com.
Visit this group at https://groups.google.com/group/cf-orm-dev.
For more options, visit https://groups.google.com/d/optout.



--
Cameron Childress
--
p:   678.637.5072
im: cameroncf

Spencer Neff

unread,
Jun 21, 2016, 4:56:32 PM6/21/16
to cf-orm-dev
Thanks very much for your suggestions!

One important thing I forgot to mention: this is an intermittent problem. Sometimes when I restart the server the cfc mappings are correct, other times I have this problem where seemingly only this single component has the incorrect mapping.

None of our CFC's declare EntityName, and we aren't always using the full name with EntityNew either. I'm making these changes now. When I try <cfcomponent entityName="com.model.ORM.EventQuestionLink">, I get the error: "A CFC with entityname EventQuestionLink could not be found." If I use <cfcomponent entityName="EventQuestionLink"> then there is no error.

Right now things are working smoothly... if you never hear from me again in this thread, your suggestion 2 must have been the fix.

Message has been deleted

Spencer Neff

unread,
Jun 22, 2016, 4:34:05 PM6/22/16
to cf-orm-dev
On Tuesday, June 21, 2016 at 2:54:59 PM UTC-5, Spencer Neff wrote:

This continues to be an intermittent, very frustrating problem.

In EventQuestionLink.cfc:
component extends="Entity" persistent="true" table="event_questions_link" schema="dbo" output="false" cacheuse="transactional" entityName="EventQuestionLink"

(I try using "com.model.ORM.EventQuestionLink" and "model.ORM.EventQuestionLink" for entityName, but both result in component not found error. Previously there was no entityName value.)

In EventService.cfc:

var newLink = new com.model.ORM.EventQuestionLink();
newLink.setEventID(arguments.eventID);
newLink.setQuestionID(questionID);
// var newLink = EntityNew("EventQuestionLink", {eventID:arguments.eventID, questionID:questionID});
writeDump(var=newLink,abort=true);
EntitySave(newLink);

The resulting WriteDump shows: "component model.ORM.EventQuestionLink extends com.model.ORM.Entity". I dump my ORMsettings struct and see that cfcLocation is correct. Ends up the same whether I use "new com.model.ORM.EventQuestionLink()" or "EntityNew('EventQuestionLink')" version.

I don't understand how EntityNew("EventQuestionLink") is working totally fine and knows what directory to get a new EventQuestionLink, but then EntitySave() wants to save it in the wrong place!

On application startup, sometimes this entity is mapped correctly, other times not.

Nando Breiter

unread,
Jun 22, 2016, 6:56:08 PM6/22/16
to cf-or...@googlegroups.com
Spencer, 

Do you have cfclocation set in this.ormsettings? 

I develop on a Mac and my production servers are all Linux and have never seen this error. In Application.cfc, I have 

this.ormsettings = {
cfclocation="./entityDirectory",
                etc ...
}

where "entityDirectory" is directly under Application.cfc, and all the app's ORM cfc's are in that directory.

I reference all entities with the name only, no dot path, and it has always worked flawlessly.





Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

Spencer Neff

unread,
Jun 22, 2016, 8:51:43 PM6/22/16
to cf-orm-dev
Hey Nando, thanks for your input. We have a multi-instance application. Subdirectories /regionA, /regionB, /regionC, etc., as well as a /com that contains all the code for the site.

Each region subdirectory contains a symlink to the upper com directory and an Application.cfc that sets this.ormSettings.cfcLocation = '/com/model/ORM'.

Each region subdirectory has an empty ApplicationProxy.cfc that extends Application.cfc. In /com an Application.cfc sets all common app settings and also extends ApplicationProxy.cfc. This way our "inner" Application.cfc includes ApplicationProxy, which is just there to include the "outer" Application.cfc (region specific app settings).

Hope this gives you something to go on. It seems to me that the mapping done on server start is happening inconsistently somehow? I have been trying moving the this.ormSettings.cfcLocation around between the inner/outer Application.cfc, but the intermittent nature of the problem is making it hard for me to tell what, if anything, my changes are doing... Might not even be looking in the right place! But my hunch is that this line is not being read early enough.

On Tuesday, June 21, 2016 at 2:54:59 PM UTC-5, Spencer Neff wrote:

Nando Breiter

unread,
Jun 23, 2016, 6:45:38 AM6/23/16
to cf-or...@googlegroups.com
Spencer, did you try setting an array of directories in the main Application.cfc that would include all directories ACF should use to find persistent CFC's? You could also try removing the setting and see what happens. (If the error doesn't go away when you remove the setting, to me, that would indicate the issue is elsewhere, perhaps an incorrectly hard-coded path somewhere?)

cfclocation

 

Specifies the directory (or array of directories) that should be used by ColdFusion to search for persistent CFCs to generate the mapping. If cfclocation is set, ColdFusion looks at only the paths specified in it. If it is not set, ColdFusion looks at the application directory, its sub-directories, and its mapped directories to search for persistent CFCs.


(Quick google search led me to the ACF 9 docs, but the array of directories thing should be the same for ACF 10.)



Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamedia

Cameron Childress

unread,
Jun 23, 2016, 9:15:03 AM6/23/16
to cf-or...@googlegroups.com
On Wed, Jun 22, 2016 at 4:34 PM, Spencer Neff wrote:
This continues to be an intermittent, very frustrating problem.

Yup - when I have run into this before my assumption has always been that whatever internal event that loads all of the CFCs into Hibernate puts then into a totally random order and makes some assumptions about where they should be mapped. Depending on where your "first hit" on the app comes from (or something) it's a total crap shoot on those assumptions. The only way I have reliably fixed this in all situations is to be ridiculously consistant with my CFC naming using the LONG version.
 
In EventQuestionLink.cfc:
component extends="Entity" persistent="true" table="event_questions_link"  schema="dbo" output="false" cacheuse="transactional" entityName="EventQuestionLink"

So this would become:

component 
  extends="com.model.ORM.Entity" 
  persistent="true" 
  table="event_questions_link"  
  schema="dbo" 
  output="false" 
  cacheuse="transactional" 
  entityName="com.model.ORM.EventQuestionLink"

....and relationships need to look like this...

property name='something'
  fieldtype='many-to-one'
  cfc='com.model.ORM.EventQuestionLink'
  fkcolumn= 'whatever_id';

....and any init() functions need to look like this....

public com.model.ORM.EventQuestionLink function init() {
  return this;
}

The long name all the time EVERYWHERE.

I would also make sure you have the com folder mapped in your Application.cfc like this (or in the CFAdmin):

this.mappings['/com']= expandPath('../com/');

Nando's comments are solid too.

-Cameron

Spencer Neff

unread,
Jun 24, 2016, 6:22:33 PM6/24/16
to cf-orm-dev
I spent one more day trying and hoping to resolve this. We have 100+ ORM/CFC's and 1000's of cases of EntityNew that would need to be updated in order to follow all of Cameron's advice completely. There were changes that seemed to help, but as soon as I start to feel optimistic the error will come back.

Thanks for your help. Unfortunately, I likely won't be pursuing it anymore. We are anticipating moving production from ACF10 to Lucee5, so I'm taking this opportunity to switch now. I think the problem will go away... also now on orders to set up a Windows box.

On Tuesday, June 21, 2016 at 2:54:59 PM UTC-5, Spencer Neff wrote:

Cameron Childress

unread,
Jun 25, 2016, 12:49:57 PM6/25/16
to cf-or...@googlegroups.com
On Fri, Jun 24, 2016 at 6:22 PM, Spencer Neff wrote:
Thanks for your help. Unfortunately, I likely won't be pursuing it anymore. We are anticipating moving production from ACF10 to Lucee5, so I'm taking this opportunity to switch now.

Not a bad idea regardless.
 
I think the problem will go away... also now on orders to set up a Windows box.

Doubt Windows will do anything. But, orders are orders.... Now you can spend days and days setting up a new development environment on an all new platform!

-Cameron
Reply all
Reply to author
Forward
0 new messages