[Coldbox 3.7.0] Adding the ColdBox context to a manually configured wirebox injector.

I am attempting to configure a wirebox injector object manually in Application.cfc so that some of our legacy code can access objects managed by the IOC container. However I am getting an error when I attempt to do this.

In my Application.cfc (onApplicationStart), I have:

`
87 application.cbBootstrap = CreateObject(“component”,“coldbox.system.Coldbox”).init(this.cbSettings.COLDBOX_CONFIG_FILE, 8 this.cbSettings.COLDBOX_APP_ROOT_PATH, this.cbSettings.COLDBOX_APP_KEY, this.cbSettings.COLDBOX_APP_MAPPING);
88 application.cbBootstrap.loadColdbox();
89 application.wbInjector = createObject(“component”,“coldbox.system.ioc.Injector”).init(binder=“intranet.sqbox.config.WireBox”, coldbox=application.cbBootstrap);

`

When this code runs I get the following error:

`
Oops! An error has occurred
Please provide the following information to technical support:

Error: component [coldbox.system.Coldbox] has no function with name [getLogBox]

Template: C:\inetpub\wwwroot\Version130Dev\coldbox\system\ioc\Injector.cfc

Detail:

Error on line: 113 in C:\inetpub\wwwroot\Version130Dev\coldbox\system\ioc\Injector.cfc
Error on line: 92 in C:\inetpub\wwwroot\Version130Dev\coldbox\system\ioc\Injector.cfc
Error on line: 89 in C:\inetpub\wwwroot\Version130Dev\Intranet\Application.cfc

Type: expression

`

Any ideas where I might be going wrong?

I do have logbox configured in the configure method of my Coldbox.cfc file and it seems to work fine:

`

logBox = {
appenders = {
// AsyncRollingFileAppender outputs to the C:\inetpub\logs\IC\APPLICATION.log file
application = {
class=“coldbox.system.logging.appenders.AsyncRollingFileAppender”,
levelMax=“DEBUG”,
levelMin=“FATAL”,
properties={
filePath=“C:\inetpub\logs\IC”,
autoExpand=“false”,
fileMaxSize=“3000”,
fileMaxArchives=“5”
}
}
},
root = { levelmax=“ERROR”, levelMin=“FATAL”, appenders="" },
categories = {
“intranet” = { levelmax=“DEBUG”, levelMin=“FATAL”, appenders="
" },
“coldbox.system.orm” = { levelmax=“DEBUG”, levelMin=“FATAL”, appenders="" },
“_testcases” = { levelmax=“DEBUG”, levelMin=“FATAL”, appenders="
" }
}

};

`

Because the injector takes in a controller, not the bootstrap object.

You need to do this:
createObject(“component”,“coldbox.system.ioc.Injector”).init(binder=“intranet.sqbox.config.WireBox”, coldbox=application.cbController);

Also, make sure your intranet.sqbox.config.WireBox, in the scope storage section, does NOT have a key of “wirebox”, but a key of “wbInjector”. Then you do not need the application.wbInjector in the create object assignment, wirebox registers itself in application scope.

signature0.jpg

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

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Thanks Luis, that worked, though changing the scope storage section to “wbInjector” caused a problem with injecting wirebox objects into non-legacy code using the full framework. The error indicated that internally, application.wirebox is expected. I think I will just refactor our legacy code to access wirebox at application.wirebox instead of application.wbInjector.

Thanks again,

Ryan

I would suggest you use a facade instead so you don’t bind yourself to application.wirebox.

signature0.jpg

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

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano