Error when autowiring plugin in model

Hi All,

I am currently having a problem when I try to autowire the
ApplicationStorage plugin into my service layer.

I want the model to write some values into the application storage, so
using CF3.0 and wirebox, I set a property in my model to autowire
coldbox:plugin:applicationstorage,

But when I do that, I get the following error:

key [CACHE] doesn't exist in struct
(keys:CORE_EXTENSIONS_PATH,CACHEDICTIONARY,CUSTOMPLUGINSEXTERNALPATH,EXTENSIONSPATH,EXTENSIONSPHYSICALPATH,CORE_PLUGINS_PATH,CUSTOMPLUGINSPHYSICALPATH,CUSTOMPLUGINSPATH)

Am I doing something wrong, or is this a bug in the code?

Kind regards,

Erik-Jan

Can you provide a stack trace please?

Thanks!

~Brad

Sure, here you go:

  The Error Occurred in
/mnt/hgfs/www/replacedirect.v2/coldbox/system/web/services/
PluginService.cfc: line 367

    365: <cfargument name="module" type="any" required="false"
default="" hint="The module to retrieve the plugin from"/>
    366: <cfscript>
    367: var pluginKey = instance.cache.PLUGIN_CACHEKEY_PREFIX &
arguments.plugin;
    368:
    369: // A module Plugin

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/web/services/
PluginService.cfc: line 140

    138: <!---
************************************************************* --->
    139: <cfscript>
    140: var pluginKey =
getPluginCacheKey(argumentCollection=arguments);
    141: var pluginDictionaryEntry = "";
    142: var refLocal = structnew();

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/web/
Controller.cfc: line 325

    323: return
services.pluginService.new(arguments.plugin,arguments.customPlugin,arguments.module,arguments.init);
    324: }
    325: return
services.pluginService.get(arguments.plugin,arguments.customPlugin,arguments.module,arguments.init);
    326: </cfscript>
    327: </cffunction>

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/dsl/
ColdBoxDSL.cfc: line 140

    138: case "setting" : { return
instance.coldbox.getSetting(thisLocationKey); }
    139: case "fwSetting" : { return
instance.coldbox.getSetting(thisLocationKey,true); }
    140: case "plugin" : { return
instance.coldbox.getPlugin(thisLocationKey);}
    141: case "myplugin" : {
    142: // module plugin

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/dsl/
ColdBoxDSL.cfc: line 41

    39: case "javaloader" : { return
getJavaLoaderDSL(arguments.definition);}
    40: case "entityService" : { return
getEntityServiceDSL(arguments.definition);}
    41: case "coldbox" : { return
getColdboxDSL(arguments.definition); }
    42: }
    43: </cfscript>

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/
Builder.cfc: line 302

    300: // ColdBox Context DSL
    301: case "ioc" : case "ocm" : case "webservice" : case
"javaloader" : case "entityService" :case "coldbox" : {
    302: refLocal.dependency =
instance.coldboxDSL.process(arguments.definition); break;
    303: }
    304: // CacheBox Context DSL

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/
Injector.cfc: line 539

    537: else if( structKeyExists(arguments.DIData[x], "dsl") ){
    538: // Get DSL dependency by sending entire DI structure to
retrieve
    539: refLocal.dependency =
instance.builder.buildDSLDependency( arguments.DIData[x] );
    540: }
    541: // else we have to have a reference ID or a nasty bug has
ocurred

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/
Injector.cfc: line 449

    447: }
    448: // DIProperty injection
    449: processInjection( targetObject, thisMap.getDIProperties(),
arguments.targetID );
    450: // DISetter injection
    451: processInjection( targetObject, thisMap.getDISetters(),
arguments.targetID );

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/scopes/
Singleton.cfc: line 48

    46: instance.singletons[cacheKey] =
instance.injector.buildInstance( arguments.mapping,
arguments.initArguments);
    47: // wire it
    48:
instance.injector.autowire(target=instance.singletons[cacheKey],mapping=arguments.mapping);
    49: // log it
    50: if( instance.log.canDebug() ){

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/
Injector.cfc: line 254

    252:
    253: // Request object from scope now, we now have it from the
scope created, initialized and wired
    254: target =
instance.scopes[ mapping.getScope() ].getFromScope( mapping,
arguments.initArguments );
    255:
    256: // Announce creation, initialization and DI
magicfinicitation!

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/config/
Binder.cfc: line 775

    773: // is it eager?
    774: if( thisMapping.isEagerInit() ){
    775: instance.injector.getInstance( thisMapping.getName() );
    776: }
    777: }

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/
Injector.cfc: line 156

    154:
    155: // process mappings for metadata and initialization.
    156: instance.binder.processMappings();
    157:
    158: // Announce To Listeners we are online

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/ioc/
Injector.cfc: line 90

    88:
    89: // Configure the injector for operation
    90: configure( arguments.binder, arguments.properties);
    91:
    92: return this;

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/web/services/
LoaderService.cfc: line 159

    157: // If using cf8 and above then create it with our binder
    158: if( controller.getCFMLEngine().isMT() AND
wireboxData.enabled ){
    159: oInjector =
createObject("component","coldbox.system.ioc.Injector").init(wireboxData.binderPath,controller.getConfigSettings(),
controller);
    160: controller.setWireBox( oInjector );
    161: }

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/web/services/
LoaderService.cfc: line 77

    75:
    76: // Create WireBox Container
    77: createWireBox();
    78:
    79: // Execute onConfigurationLoad for coldbox internal services()

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/Coldbox.cfc:
line 71

    69: application[appKey] =
CreateObject("component","coldbox.system.web.Controller").init(COLDBOX_APP_ROOT_PATH);
    70: // Setup the Framework And Application
    71:
application[appKey].getLoaderService().loadApplication(COLDBOX_CONFIG_FILE,COLDBOX_APP_MAPPING);
    72: // Application Start Handler
    73: if
( len(application[appKey].getSetting("ApplicationStartHandler")) ){

called from/mnt/hgfs/www/replacedirect.v2/coldbox/system/Coldbox.cfc:
line 102

    100:
    101: <!--- Reload ColdBox --->
    102: <cfset loadColdBox()>
    103: </cfif>
    104: </cflock>

called from/mnt/hgfs/www/replacedirect.v2/Application.cfc: line 63

    61:
    62: <!--- Reload Checks --->
    63: <cfset reloadChecks()>
    64:
    65: <!--- Process A ColdBox Request Only --->

Is the object you trying to wire eagerly inited?

Yes, Luis, that it is! Could that be the problem? I will remove the
eager init property and let you know if it works...

Kind regards,

Erik-Jan

Yes, that would be the problem because the injector initializes before the plugin services in ColdBox, so when you call for a plugin, the plugin service is still waiting for the injector to init. Chicken and the egg problem. At this point the solution is to NOT use eager init when using ColdBox plugins in your wirebox managed objects.

Luis F. Majano
President
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

EJ, Did you get past this?

Hi Aaron,

Yes, I just got around to testing this, and removing the eagerinit
solves my problem! Thanks for the help.

Kind regards,

Erik-Jan