I managed to find out where things go wrong.
I have a main.services.xml, versioncontrol.services.xml and
profile.services.xml. The latter two are subapplications, therefore
carrying their own services.
Now, I have a service that is used by both subapplications, so I figured
I define it in main.services.xml (which also holds all services for the
main application), so I have to define it only once. And this is where
coldspring returns 0 instead of the actual object.
This led me to the bug in getBeanFromSingletonCache() I wrote about in
my last email. After fixing the bug (have objExists set to false when
there's no object around) I quickly found out what the problem actually is:
When a service is defined in main.services.xml, but only is used by sub
services.xml files, the service is never instantiated. And that leads to
an error when coldspring tries to feed the service into a mach-ii
listener (or any other bean for that matter).
If I use the service in the main application (by simply putting a setter
in a listener), everything works as it should. Apart from the fact that
you have a setter in a place it has no use.
Note: I had to alter containsBean() so it checks its possible parent for
the bean as well, to get this sub-services.xml stuff working in the
first place.
Regards,
Ruud
Ruud Hermans schreef:
Hello,
I've encountered a situation where mach-ii throws an error because
coldspring is trying to put the value 0 instead of an object into a
listeners' setter. I'm working my way through the coldspring code
(BER) to find out why this is happening.
In doing so, I noticed a strange bit of code in the method
getBeanFromSingletonCache in DefaultXmlBeanFactory.cfc.
Here's the code:
<cffunction name="getBeanFromSingletonCache" access="public"
returntype="any" output="false">
<cfargument name="beanName" type="string" required="true" />
<cfset var objRef = 0 />
<cfset var objExists = true />
<cflock name="bf_#variables.beanFactoryId#.SingletonCache"
type="readonly" timeout="5">
<cfif StructKeyExists(variables.singletonCache, beanName)>
<cfset objRef = variables.singletonCache[beanName] />
<cfelse>
<cfset objExists = true />
</cfif>
</cflock>
<cfif not(objExists)>
<cfif isObject(parent)>
<cfset objRef =
variables.parent.getBeanFromSingletonCache(arguments.beanName)>
<cfelse>
<cfthrow message="Cache error, #beanName# does not
exists">
</cfif>
</cfif>
<cfreturn objRef />
</cffunction>
Now, if you ask me, the variable objExists will never be false,
therefore the second part of the function will never be executed.
Just thought I mention it.
Oh, and the component variable 'parent' in DefaultXmlBeanFactory.cfc
isn't scoped in about 16 places.
And now I'll just go back figuring out this 0-thing.
Regards,
Ruud