I have a bean that is created during the before() ...
# fw1
s
I have a bean that is created during the before() of a controller cfc: request.shoppingCart = variables.beanFactory.getBean("shoppingCart"); This normally runs fine without issues. But every now and then FW/1 seems to get into a mode returning non-stop "bean not found: shoppingCart" exceptions and it takes a reload to fix. Any ideas? Lucee version 6.0.0.585 Ubuntu version 22.04.3 LTS FW/1 version 4.3.0
a
Is
shoppingCart
defined as a transient?
Guessing you are using DI1 (which is the default with FW1)
Is
reloadApplicationOnEveryRequest
set to false?
Also where is
variables.beanFactory
being set? Is that being passed in using
property beanfactory
in your controller?
s
beanFactory - Yes, via property beanFactory. reloadApplicationOnEveryRequest - unset, so default. DI1 - Yes, the FW/1 default. shoppingCart - transient? I'm not sure what you mean. In the controller before() it is created: request.shoppingCart = variables.beanFactory.getBean("shoppingCart");
a
By transient - I mean is it the same object that you get each time (by reference) or is it a brand new object on each request. DI1 allows you to define beans as transient or singleton. With a singleton, every time you get it from the beanfactory it is the same object. With a transient, the beanfactory will return a brand new version of it. I can't tell by looking at your code which it is. Yes, I can can see you setting a reference on each request, but I don't know if it's a reference to a singleton or a transient. https://framework-one.github.io/documentation/4.0/using-di-one/#specifying-additional-transient-beans
Also as a side-note. There is no need to use the
request
scope in FW1 as you have the
rc
scope already which does not leak into everything.
s
I did have a reason for request scope, I cannot remember at the moment. Something did not have rc passed to it. I was not aware of the transient behavior and did not know it even existed with beans. I assumed it was being created for each request. Whatever the default is, which may be an issue if the default is singleton.