Circular Dependency Injection

If I am wrong, I do apologize. I was mostly going off the OP's post on 6/7 when he stated that he had configured setter injection, however "the handler the system spins for a long time before eventually giving me a JRun 500 error". I have used LW in the past, and without fail any JRun 500 errors I have received have been do to a circular dependency that recurses until memory is gone.

Perhaps there is still something else at play. I don't believe the OP mentioned what version of LW he was using, but perhaps I'll try a quick test tonight to see what happens.

Again, I didn't mean to mis-represent LW-- I was going off the OP's error report and my own (slightly old) experience with it.

~Brad

As my wife
sometimes says “We’re in violent agreement!” :slight_smile: :slight_smile:

I like it :slight_smile:

Luis F. Majano
President
Ortus Solutions, Corp

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

Sure - be interested to note what experience in the version in ColdBox, but I know the core project can handle circular setter dependencies as I've been using it to do just that ever since I wrote it!

Best Wishes,
Peter

I am pretty sure LW supports circular dependencies via setter injection, in both versions.

Luis F. Majano
President
Ortus Solutions, Corp

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

I’m the OP here, running ColdBox 3.0 M5 and whatever version of LightWire comes with it. I downloaded the latest version of LW from RIAForge and they appear to be the same, so last stable release.

Perhaps I’m just mixing/matching my ColdBox and Lightwire incorrectly? To reiterate, in my LW BeanConfig here are the two declarations:

// Pick Service

addTransient(“components.PickService”);
addConstructorProperty(“PickService”, “datasource”, local.datasource);

// Pool Service

addTransient(“components.PoolService”);
addConstructorProperty(“PoolService”, “datasource”, local.datasource);

// Add setter dependencies for circular
addSetterDependency(“PoolService”,“PickService”);

addSetterDependency(“PickService”,“PoolService”);

In the ColdBox config:

ioc = {
framework = “lightwire”,
reload = false,
objectCaching = true,
definitionFile = “config.BeanConfig”
};

In the services themselves I took our the and have a setter method in each. Finally, in one of my handlers I declare both like this:

… etc…

Whenever I access ANY method in this handler - even a blank one that just outputs a view - the request runs until it times out or is out of memory. If I take out either of the cfproperties it runs fine.

Everyone seems to agree LW supports circular dependency via setter injection so that means I’m probably doing something wrong in my ColdBox or LW setup.

Thanks,

William

Hmm, I don’t use LW in CB so I’ll have to defer to Luis. Sorry!

Best Wishes,

Peter

Try doing some unit tests for this and seeing and pinpointing what is the culprit for this.

Luis F. Majano
President
Ortus Solutions, Corp

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