[ColdBox 4.0.0] Module's models in subfolder

I’m trying to inject some models that are in models subfolder from my module.

My folder structure:

`

  • Models
    +Config
    Config.cfc
    +Adapter
    AbstractAdapter.cfc
    Parser.cfc

``

`

In my Parser.cfc I try to inject Config.cfc

`
property name=“config” inject=“config@whois”;

`

I got this error:

`
invalid component definition, can’t find component [Config]

`

What is wrong? I have tried also with

`
property name=“config” inject=“config.config@whois”;

`

In your modules there is a file called Modules.cfc. How are you setting the binder mapping? Also, where is your modules located? Is it under the main application?

Is the Config.cfc being mapped in Module.cfc as follows?
binder.map(“config@whois”).to(“whois.model.Config”);

In my ModuleConfig.cfc I have this settings:

`

// Model Namespace
this.modelNamespace = “whois”;
// CF Mapping
this.cfmapping = “whois”;
// AutoMap
this.autoMapModels = true;
// CF Mapping
this.cfmapping = “whois”;

`

Shouldn’t this automap all models? If I put Config.cfc under the models folder, it get injected.

This is new to me. Never tried using the new properties defined in the following document at http://wiki.coldbox.org/wiki/WhatsNew:4.0.0.cfm#Module_Config_New_Properties

According to the document your configuration should work as long as the Config.cfc is located under the model directory of the module.

I tested this by creating a site and module with CommandBox and it seems to work fine.

Double check your modelNameSpace setting-- if it is blank, your “config” model mapping will get overwritten by the WireBox binder config which has the same mapping name.

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. Now it works. I was running on commandbox and probably something was in the cache that gives me error. After some server stop and start it works great now.