Explicit getter not accessible from a call initiated via another CFC


When I inject into a CFC, using an explicit setter, in Lucee/Railo/ACF, the
‘injected into’ CFC seems to lose access to the injected CFC’s getter, when
the request is initiated from a third CFC.


CF page template test.cfm calls test3Service.Bar()
test3Service.Bar() calls getTest1Service.Bar() [implicit getter]
getTest1Service.Bar() calls getTest2Service.Bar() [explicit getter]

The reason for the explicit getter is that test1Service.cfc is dependent on
test2Service.cfc, and test2Service.cfc is dependent on test1Service.cfc


Element TEST2SERVICE is undefined in VARIABLES.


My CFCs are created via a service factory that loops through a list and
instantiates each service.
It then calls setters for the circular dependents.

Below, is part of the application.cfc. the service factory component and
three service components from this framework.

I am using accessors for non circular dependencies, and explicit getters &
setters for circular dependencies.
Accessors create synthesized getters & setters, which reduces the amount of
code. These are set in the constructor.
The explicit getters & setters are created the old fashioned way, but allow
the CFC to initialize, before injection.

Part of ‘OnRequestStart’ method of application.cfc






#foo# #bar#

#foo# #bar#

#foo# #bar#

test.cfm output

foo bar

foo bar


The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging
Error Occurred While Processing Request
Element TEST2SERVICE is undefined in VARIABLES.

The error occurred in
line 40
Called from
line 86
Called from
line 51
Called from C:/ColdFusion11/cfusion/wwwroot/establishmindfulness/test.cfm:
line 2925

38 :
39 :
40 :
41 :
42 :


Message string Component [test1Service] has no accessible Member with


When I change the test1Service.getTest2Service() to:

The error dissappears and I get the final correct output:

foo bar

foo bar

foo bar


But, this seems a little messay to me, to have to keep resetting the
component in the getter.
Surely, the injection should persist for the applications lifetime, as my
framework is saved into the application scope.
What, I don’t understand, is why the injection works, when calling the
component method directly, but does not persist, when I call via an

If anyone is interested, I have resolved the problem.

After many days of thought about this issue, I suddenly had a ‘eureka’
By getting rid of all the implicit setters, and adding all my connecting
services via explicit getters & setters, everything worked!

I reckon this is why implicit setters are not used, as much, to set
components, because they need to be set inside the constructor.
This means that implicitly set components lose scope when accessing a
component that uses an explict getter/setter.

Now, I understand why MURA CMS has so many getter & setters just below its
cfc constructor code.