Issue with dependency injection in my handlers

I just recently switched to Coldbox 3.5 and went from using Coldspring
to Wirebox.

I removed all references to getPlugin('ioc').getBean('myModelObject')
as well as all references to getMyPlugin('myPlugin') and
getPlugin('messagebox') and replaced them with the following notation:

// top of the handler
component name="Page" extends="coldbox.system.eventhandler"
output="false" autowire="true" singleton {

// properties
  // inject model objects
  property name="oMediaPartnerManager"
  property name="oPageManager" inject="model:pageManager";
  property name="oMerchantManager" inject="model:merchantManager";

  // inject plugins
  property name="oSession" inject="coldbox:plugin:sessionstorage";
  property name="oSecurity" inject="coldbox:myplugin:security";
  property name="oUtility" inject="coldbox:myplugin:utility";

// example calls in my functions
var description =

var qMerchant =

Most of the time this is working, but on our production server, I am
getting occasional failures: Error Messages: Variable OUTILITY is

This is happening on both injected plugins and model objects. My
instinct is that there may be a caching issue, but I am not sure where
that would be. I listed my settings on another post if that is

Thanks in advance for any help on this.


I am guessing, the server was restarted to make all changes take effect?

Also is your utility plugin a singleton?

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager:


Yeah, I restarted the server, cleared the cache and reinited.

<cfcomponent name="utility" hint="Utility functions"
extends="coldbox.system.plugin" output="false" cache="true"

That is the declaration of the utility plugin. I don't have it set as
singleton and maybe the cache setting is antiquated?

not that is fine, but your injection is wrong. This will cause memory leaks as you are injecting a volatile object into your handler which is a singleton. So if you utility object expires then we are in limbo. This side effect is called scope widening injection:

I would suggest you either get the plugin when you need it via getMyPlugin() and put it in rc or prc scope and use it. Else, inject it as a provider if you still want the plugin to expire.

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager:


Also, I have a few model objects that are having this same failure.
Here is an example of one of those declarations:

<cfcomponent name="moduleManager" output="yes" singleton>

Also verify you are not using things like singletonReload or configAuto reload

Luis F. Majano
Ortus Solutions, Corp

ColdBox Platform:
Linked In:
IECFUG Manager:


Ah, I see... That makes a lot of sense and sounds like my exact issue.
This being the case, when would you want to inject using a property?
Only when you are not caching the calling object? Would you recommend
that I also use getModel() to get my singleton model objects, rather
than using the property notation?

Would another solution be to make sure all objects that are injected
into singletons are also singletons?

I would ask why your handler isn't a singleton? Sometimes there is a use case for it not being, but it is my the exception then the rule.


All of my handlers are singletons, but if I understand correctly, that
is what is causing the scope widening injection.

Oh, opps, sorry about that, I misread earlier....

To answer your question though, yes, all objects that are injected into singletons should be singletons, or else you will need to use a provider.


I just verified that my two model objects that seem to have dropped
off are singletons, but my plugins aren't. I will change the plugins
so that they are doing getPlugin() and getMyPlugin(), but can you
think of any reason why the singleton model objects would be expiring,
when the singleton handlers do not? Maybe I am not fully understanding
the issue.