ORM issue - Messages: No entity (persitent component) with name [Contact] found, available entities

I’m just getting started with ColdBox on Lucee and was attempting to test out the ORM functionalities but I’ve hit a snag.

Initially, I was playing with an existing app and had some issues, to try to isolate my issue I started with a brand new project.

From memory here’s what I’ve done based on http://coldbox.ortusbooks.com/content/index.html

I created my app in

c:\inetpub\www\myapp\ with install coldbox

coldbox create app name=MyApp skeleton=AdvancedScript

coldbox create controller name=hello actions=index,echo

The hello world ran fine in the built-in CF engine so I moved on and configured it with a Lucee service and an IIS site on my locahost at local.myapp.

I tried running the hello world action again and it ran fine so IIS and Lucee are configured properly.

Moved on to try and enable the ORM - 

I added the following to my application.cfc

// ORM Settings
this.ormEnabled       = true;
this.datasource          = "contacts";
this.ormSettings      = {
    cfclocation = "models",
    dbcreate    = "update",
    logSQL         = true,
    flushAtRequestEnd = false,
    autoManageSession = false,
    eventHandling       =  true,
    eventHandler      = "cborm.models.EventHandler"
};

and added  the following to coldbox.cfc configure()

orm = { injection = { enabled=true } }; 

I created the contacts datasource within Lucee server admin (MS SQL) 

Then I ran 

coldbox create orm-entity entityName=contacts primaryKey=contactID properties=firstName,lastName,email --activeEntity --open

This created a Contacts.cfc file under model as expected.

Afterward I ran

coldbox create handler name=contacts actions=index,editor,delete,save

This created the handler and I was able to load the index action fine.

I then modified the handler's index function to:

function index(event,rc,prc){
  prc.contacts = entityNew("Contact").list(sortOrder="lastName",asQuery=false);
  event.setView( "contacts/index" );
}

I restarted the Lucee services to make sure everything would reinit properly and tried loading it which gives me the following error:

Messages: No entity (persitent component) with name [Contact] found, available entities are [] 

From what I was able to gather, I think this might mean that ColdBox is not finding my contact model or that there is a syntax error within it preventing it from getting init'd, but I'm not sure where to check. 

My orm.log under C:\inetpub\www\myapp\WEB-INF\lucee\logs is empty

The full CFC code is:

/**
* A cool contacts entity
*/
component persistent="true" table="contacts" extends="cborm.models.ActiveEntity"{

	// Primary Key
	property name="contactID" fieldtype="id" column="contactID" generator="native" setter="false";

	// Properties
	property name="firstName" ormtype="string";
	property name="lastName" ormtype="string";
	property name="email" ormtype="string";

	// Validation
	this.constraints = {
		// Example: age = { required=true, min="18", type="numeric" }
	};

	// Constructor
	function init(){
		super.init( useQueryCaching="false" );
		return this;
	}
}

Hi

Try to reload framework index.cfm?fwreinit=1

I have - I tried restarting the Lucee service and it didn’t help.

Is your ORM event handler set in Application.cfc ORM settings?

It needs to be:

eventHandler = "cborm.models.EventHandler"

Yes I have the following in my application.cfc

// ORM Settings
this.ormEnabled = true;
this.datasource = “contacts”;
this.ormSettings = {
cfclocation = “models”,
dbcreate = “dropcreate”,
logSQL = true,
flushAtRequestEnd = false,
autoManageSession = false,
eventHandling = true,
eventHandler = “cborm.models.EventHandler”
};

This is under this.javaSettings = { loadPaths = [ “lib” ], reloadOnChange = false };

and before the onApplicationStart() from the default app.

I’ve zipped up the project file since there’s nothing sensitive in there, it’s basically the app that the documentation has you build (with something I missed obviously…)

myapp.zip (3.4 MB)

Added the following to test my action and I was able to get the rows from the table so at least I know the table exist (I created it manually) and the datasource isn’t the issue.

var contacts = queryExecute(“select * from contacts”, {}, {datasource=“contacts”} );
writeDump(contacts );
abort;

SOLVED -

I must have missed it in the doc, but I remembered while reading up on ColdBox 4 that there was a switch to a modular architecture. Turns out I was missing the entire module!

Did

box install cborm

``

and updated my model to extend from the modules directory instead -

extends="modules.cborm.models.ActiveEntity"

``

Surprise, it works :)

``

Is the standard to extend from the modules directory? cause http://coldbox.ortusbooks.com/content/models/coding_activeentity_style/contactcfc.html doesn't refer to it.