Explicit getter not accessible from a call initiated via another CFC

Issue:

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.

Scenario:

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

Error:

Element TEST2SERVICE is undefined in VARIABLES.

Framework:

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

serviceFactory.cfc

test1Service.cfc

test2Service.cfc

test3Service.cfc

test.cfm

#foo# #bar#

#foo# #bar#

#foo# #bar#

test.cfm output

foo bar

foo bar

COLDFUSION:

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
purposes.
Error Occurred While Processing Request
Element TEST2SERVICE is undefined in VARIABLES.

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

38 :
39 :
40 :
41 :
42 :

LUCEE:

Message string Component [test1Service] has no accessible Member with
name [TEST2SERVICE]

UPDATE:

When I change the test1Service.getTest2Service() to:

The error dissappears and I get the final correct output:

foo bar

foo bar

foo bar

Summary:

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
intermediary.

If anyone is interested, I have resolved the problem.

After many days of thought about this issue, I suddenly had a ‘eureka’
moment.
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.