A CFC with entityname User could not be found

Directly under my model folder, I have a SecurityService.cfc component. This component has an injected property called ‘UserService’. Now, the UserService.cfc component is located under /model/User/UserService.cfc. In this same folder is a User.cfc component (/model/User/User.cfc).

Now, my UserService.cfc is defined as a VirtualEntityService object as follows:

component name=“UserService” extends=“coldbox.system.orm.hibernate.VirtualEntityService” accessors=“true” singleton {

public function init(){
super.init( entityName=“User”, useQueryCaching=true );

return this;
}

When the app loads, I am getting the error “A CFC with entityname User could not be found …”.

I am confused here - why would the application be able to find both the SecurityService.cfc and the UserService.cfc components, but not the User.cfc?

My guess is that your user cfc has a syntax or hibernate mapping error.

Thanks, but this is the all the User.cfc file contains at this point …

/**

  • I represent a User persisted entity
  • @output false
    */
    component displayname=“User” persistent=“true” accessors=“true” table=“Users” {

}

The ‘Users’ table exists in the database, so I don’t know what error would be here.

Thanks.

If you use the tables attribute then you need to reference via that name, so this

super.init( entityName=“User”, useQueryCaching=true );

becomes

super.init( entityName=“Users”, useQueryCaching=true );

I’m on my phone so I can’t test, but do you need to provide an id property?

I would definitely try the native orm methods to ensure that the entity is defined. Maybe entityNew(“User”) will yield a clue. See this related post from Ray Camden: http://www.raymondcamden.com/mobile/postDetail.cfm?post=DD8DA863-93F7-34A8-A59A9F7E63B7C226

Usually my errors always end up being entities and not any DI weirdness.

It appears to be something in the dependency injection or the application in general. I changed the component definition to include the entity name attribute as follows:

component entity=“User” persistent=“true” accessors=“true” table=“Users” {

This did not change anything, so I dropped the component into a simple standalone app that does not have ColdBox or any dependency injection involved at all and just called EntityLoad(“User”) with the same folder structure and it correctly pulled back a list of all of the records in that table.

So there is something weird with the dependency injection here as the User.cfc file is the exact same.

Thanks,
– Jeff

What does the orm logs say?

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano

Sorry for the ignorance here, but I am not aware of any logging for ORM outside of the SQL statement logging and I have not made it that far from an execution standpoint yet. Is there another log file that I am unaware of?

The entry in both the application and exception logs is:

Error creating validatorModel: SecurityServiceError building: UserService -> A CFC with entityname User could not be found. with constructor arguments: {}Mapping: {MIXINS={[]},DIPROPERTIES={[]},PROVIDERMETHODS={[]},DSL={},DISCOVERED={true},THREADSAFE={false},DISETTERS={[]},VALUE={},ONDICOMPLETE={[]},AUTOWIRE={true},CACHE={{KEY={},PROVIDER={},LASTACCESSTIMEOUT={},TIMEOUT={}}},DIMETHODARGS={[]},TYPE={cfc},DICONSTRUCTORARGS={[]},NAME={UserService},SCOPE={singleton},AUTOASPECTBINDING={true},VIRTUALINHERITANCE={},PATH={webapp.model.User.UserService},AUTOINIT={true},EAGERINIT={false},ALIAS={[UserService]},EXTRAATTRIBUTES={{}},METADATA={{ACCESSORS={true},NAME={webapp.model.User.UserService},FULLNAME={webapp.model.User.UserService},SINGLETON={},PROPERTIES={[{HINT={The queryCacheRegion name property for all query caching produced in this service},NAME={queryCacheRegion},TYPE={string},DEFAULT={ORMService.defaultCache}}, {HINT={The bit that tells the service to enable query caching, disabled by default},NAME={useQueryC…

Thanks

Perhaps a casing issue? Is your cfc named User.cfc or user.cfc.

The component is named User.cfc with a capital and I believe that is consistent throughout the application. With that said, I just restarted the CF server out of frustration and the issue disappeared, so something must have still been being cached even though I was reloading the app. Gotta love the little gremlins running around in the server.

Thanks!