ColdBox 4.0 Unknown Entity Error

I’m using criteria builder to return results from a states and provinces table using the following code:

function index(){
prc.sortColumn = "stateProviceCd";
prc.sortDirection = "asc";
prc.PageSize = 10;
prc.offset = 1;
`c = stateProvinceService.newCriteria();`
// get the results
prc.stateProvinces = c.like( "countryCd","US" )
.order( prc.sortColumn, prc.sortDirection )
.list( max=prc.pageSize, offset=prc.offset-1);
``
event.setView("admin/stateProvince/index");
}

I have properly injected the stateProvinceService in my handler:

property name="stateProvinceService" inject="entityService:stateProvince";

and i am using this exact code in another handler without a problem but I get an error in this handler: Unknown Entity: stateProvince.

What is more frustrating is that when i use the following code in the same handler, it works fine:

prc.stateProvinces = stateProvinceService.list(sortOrder="countryCd, stateProvinceCd asc",asQuery=false);

Anyone have some insight here…I’m stuck! Here is the full error dump:

Event: admin.stateProvince.index
Routed URL: admin/stateProvince/
Layout: N/A (Module: )
View: N/A
Timestamp: 09/15/2016 02:03:28 PM

Can someone help me out here please??

Dump the stateProvinceService and see if you get an object.
Is it base or virtual ORM service?

Thanks for the reply. I’m a bit new at this so please bear with me, but I believe it is the virtual Entity Service. I do get an object when i dump the stateProviceService. Also, if I use stateProviceService.list() it works just fine with no other changes in the handler, just commenting out the criteria builder code and uncommenting the list(). Its only when using the criteria builder functions that i get the Unknown Entity error.

so in essence. This works

prc.stateProvinces = stateProvinceService.list(sortOrder="countryCd, stateProvinceCd asc",asQuery=false);

This does not:

`
c = stateProvinceService.newCriteria();

// get the results
prc.stateProvinces = c.like( “countryCd”,“US” )
.order( prc.sortColumn, prc.sortDirection )
.list( max=prc.pageSize, offset=prc.offset-1);
`

Could you try to replace
c = stateProvinceService.newCriteria();

with this
var c = newCriteria();

When i tried that i got unknown function newCriteria error.