[ColdBox 4.1.0][CommandBox 2.0.0+00091] orm-crud scaffolding path error

Hi,

I’m following the CommandBox instructions for the “coldbox create orm-crud” command posted at the link below and I’m getting a path error returned. I’m hoping someone can tell me what I’m doing wrong or if this feature is implemented (I’ve noticed some commandbox featured are documented but not implement yet). I’ve search the google groups and stackoverflow for this error and came up with nothing useful.

Link to doc instructions:
http://coldbox.ortusbooks.com/content/models/coding_scaffolding/scaffold.html

First I created the model using this syntax. It worked fine and created the model.organization component (note: the ‘…’ is the other fields excluded for brevity).

coldbox create orm-entity entityName=organization table=organizations primaryKey=myID properties=col1:STRING,col2:STRING,...

Next I ran this command to create the scaffold files

coldbox create orm-crud models.Organization

Commandbox returned the following error :

ERROR: invalid component definition, can't find component [C:/apps/myapp/models/Organization]

I check the spelling and syntax of the model.organization component and looks okay to me.

`
/**

  • A cool organization entity
    */
    component persistent=“true” table=“organizations” {

// Primary Key
property name=“MyID” fieldtype=“id” column=“MyID” generator=“native” setter=“false”;

// Properties
property name=“Col2” ormtype=“STRING”;
property name=“Col3” ormtype=“STRING”;

// Validation
this.constraints = {
Col2 = { required=true }
};

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

}
`

App running on Windows 8.1, Lucee 4.5.1.008 final (installed from Commandbox), MySQL 5.6, modules installed: cbmessagebox, cbdebugger, cborm, cbi18n, cbvalidation.

Note: Since I found another post with a similar ORM question (for ColdBox, not Commandbox) it’s worth mentioning I have added the following line to my c:/apps/myapp/Application.cfc file as instructed by the docs:

this.mappings[ "/cborm" ] = COLDBOX_APP_ROOT_PATH & "modules/cborm";

I’ve also used the Virtual Service Layer commands in commandbox successfully. No pathway issues.

Thanks,
D.

PS Commandbox is very sweet tool. Kudos to the folks who developed.

I also ran the command to reinit the framework… no luck.

coldbox reinit

Thanks for the feedback. The ORM scaffolding stuff is actually pretty new. Luis added it and I actually haven’t even gotten a chance to try it yet. Since Luis uses a mac, it could be a pathing issue on Windows. Can you confirm if the file C:/apps/myapp/models/Organization exists?

The commands should actually be pretty easy to debug. You can find all the CFML for the commands under ~/.CommandBox/cfml/commands/coldbox/create/orm-crud.cfc

Edit edit that command file, then run “r” or “reload” in the shell to reload the changes and try again. You can’t dump/abort in a command, but you can print out debug info like so:

print.line( myVar )

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

The CLI commands are completely separate from the actual web server running. The CLI runs CFML but it has it’s own context that it’s executing inside of that doesn’t actually run your app.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks Brad,

Yes the C:/apps/myapp/models/Organization.cfc file exists. I’ll try your suggestion to reload the orm-crud.cfc component and let you know what happens.

Cheers.

ok, I think I found the problem.

Debugging reports error occurs at Line 49 (~.CommandBox\cfml\commands\coldbox\create\orm-crud.cfc) which looks like this:

`
49 var md = getComponentMetadata( entityPath );

`

On line 36 replaces dot notation with linux style slashes and line 37 appends the file extension.

`
35 var entityName = listLast( arguments.entity, “.” );
36 var entityCFC = fileSystemUtil.resolvePath( replace( arguments.entity, “.”, “/”, “all” ) );
37 var entityPath = entityCFC & “.cfc”;

`

Then line 49 calls getComponentMetadata() function but I believe this function requires dot notation format.

49 var md = getComponentMetadata( entityPath );

So I tried replacing entityPath with arguments.entity (which resolves to “models.organization”).

49 var md = getComponentMetadata( arguments.entity );

I reloaded CommandBox as instructed , and ran again. Same error occurred
ERROR: invalid component definition, can’t find component [models.organization]

Ideas?

That’s what I figured might be the issue. Of course, “models.organization” won’t resolve because there is no mapping called “models” inside CommandBox. The CFC functions in CF will often times accept slashes as well as dots. In the CommandBox context, the “/” mapping points to the drive root. On Unix-based OS’s (like a Mac) that would make the canonical path to the CFC start with / which would hit the default root mapping. On Windows, it starts with C: which CF doesn’t know what to do with.

The Windows workaround for now would be to strip off the drive letter and colon as well as the file extension so it looked like this:

/apps/myapp/models/Organization

or for that matter, like this:

apps.myapp.models.Organization

That should work on Windows and Unix. However, there is a big catch here that we also ran into with the “execute” command. This ONLY works on Windows when the file is on the same drive as the CommandBox folder. It’s not an issue on Unix since everything stems off of / but on Windows, if the / mapping points to C:\ and the cfc is on the D:\ drive it won’t work. The workaround for THAT (as far as I know) is to dynamically create CF mappings for each windows drive and detect the correct one to use as the root.

I documented this second issue here, but I’ve never bothered to fix it yet since most Windows people all just live on the C: drive so we’ve gotten away with never fully fixing it.

https://ortussolutions.atlassian.net/browse/COMMANDBOX-104

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Stripping the “c:” from the path worked. On windows, the entityCFC slashes return as windows backslashes ("").

49 var md = getComponentMetadata( listDeleteAt(entityCFC,1,'\') );

Thanks for the help.