Loading wirebox and then logbox into application

I have the following code loading wirebox and logbox in my

if(!structKeyExists(application, 'wireBox') || !structKeyExists(application, 'logBox') || IsDefined("url.init_app")) { //NOTE CHANGE THE TMEOUT BACK TO 10 !!!!!!

lock name=“createWireBoxAndLogboxInjectors” type=“exclusive” timeout=“0” {

/* Create the WireBox object and attach it to application.wireBox */
//Wirebox is leached into the application scope using the binder.
createObject(‘component’,‘coldbox.system.ioc.Injector’).init(‘epsys.config.coldbox.WireBox’);

//Logobox
/* Setup LogBox via the WireBox getInstance, instead of createObject */
objConfigData = application.wireBox.getInstance(“epsys.config.coldbox.epsysLogBoxConfig”);
objConfig = application.wireBox.getInstance(
name=“coldbox.system.logging.config.LogBoxConfig”
, initArguments={CFCConfig=objConfigData});

application.logBox = application.wireBox.getInstance(
name=“coldbox.system.logging.LogBox”
, initArguments={config=objConfig});

}

}

I am getting the an error

Variable OBJCONFIG is undefined

It appears to be processing this argument declaration first!

“, initArguments={config=objConfig});”

This only happens when the code is within a lock… can anyone explain this to me and propose a solution?

Thanks in advance

Alex

I have isolated the issue further…

This first example works

<cfif not structKeyExists(application, ‘wireBox’) OR not structKeyExists(application, ‘logBox’)>

/* Create the WireBox object and attach it to application.wireBox */ //Wirebox is leached into the application scope using the binder. createObject('component','coldbox.system.ioc.Injector').init('epsys.config.coldbox.WireBox');

local.objConfigData = application.wireBox.getInstance(“epsys.config.coldbox.epsysLogBoxConfig”);
local.objConfig = application.wireBox.getInstance(name=“coldbox.system.logging.config.LogBoxConfig”, initArguments={CFCConfig=local.objConfigData});

writeDump(local.objConfig);
writeOutput(’
’);
abort;

application.logBox = application.wireBox.getInstance(name=“coldbox.system.logging.LogBox”, initArguments={config=local.objConfig});

However… when I move the conditional into the cfscript block… It breaks!!! and I get the error telling me the local.objConfigData is not defined!
Very strange… nothing to do with coldbox/logbox… basic cf bug as far as I can tell!

if(!structKeyExists(application, 'wireBox') || !structKeyExists(application, 'logBox')){ stuVariables = structNew(); /* Create the WireBox object and attach it to application.wireBox */ //Wirebox is leached into the application scope using the binder. createObject('component','coldbox.system.ioc.Injector').init('epsys.config.coldbox.WireBox');

local.objConfigData = application.wireBox.getInstance(“epsys.config.coldbox.epsysLogBoxConfig”);
local.objConfig = application.wireBox.getInstance(name=“coldbox.system.logging.config.LogBoxConfig”, initArguments={CFCConfig=local.objConfigData});

writeDump(local.objConfig);
writeOutput(’
’);
abort;

application.logBox = application.wireBox.getInstance(name=“coldbox.system.logging.LogBox”, initArguments={config=local.objConfig});
}

Something like this?

http://www.andyscott.id.au/blog/interesting-coldfusion-scripting-problems-when-refactoring-code

Exactly!!

Thankyou!!