setBeanFactory method was not found

55 views
Skip to first unread message

Chuck

unread,
Dec 3, 2009, 4:32:38 PM12/3/09
to Reactor
I'm setting up Reactor in a Model-Glue environment, but Reactor threw
this error when attempting to run for the first time. Any directions
I should look?

The setBeanFactory method was not found.
Either there are no methods with the specified method name and
argument types, or the setBeanFactory method is overloaded with
argument types that ColdFusion cannot decipher reliably. ColdFusion
found 0 methods that matched the provided arguments. If this is a Java
object and you verified that the method exists, you may need to use
the javacast function to reduce ambiguity.

The error occurred in C:\Websites\157900dq4\Frameworks\Reactor\reactor
\reactorFactory.cfc: line 135
Called from C:\Websites\157900dq4\Frameworks\ColdSpring\beans
\DefaultXmlBeanFactory.cfc: line 902
Called from C:\Websites\157900dq4\Frameworks\ColdSpring\beans
\DefaultXmlBeanFactory.cfc: line 632
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\externaladapters\ioc\ColdSpringAdapter.cfc: line 22
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\ModelGlue.cfc: line 195
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture\modules
\orm\controller\GenericORMController.cfc: line 27
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\eventrequest\EventContext.cfc: line 298
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\eventrequest\EventContext.cfc: line 225
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\eventrequest\phase\Population.cfc: line 23
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\eventrequest\EventContext.cfc: line 155
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\ModelGlue.cfc: line 215
Called from C:\Websites\157900dq4\Frameworks\ModelGlue\gesture
\ModelGlue.cfm: line 58
Called from C:\Websites\157900dq4\mg\index.cfm: line 49

133 : <cfargument name="factory" type="coldspring.beans.BeanFactory"
required="true" />
134 : <cfset variables.BeanFactory = arguments.factory />
135 : <cfset getObjectFactory().setBeanFactory( arguments.factory )>
136 : </cffunction>
137 :


I have the latest head from the svn.

Mark Drew

unread,
Dec 3, 2009, 4:44:08 PM12/3/09
to reacto...@googlegroups.com
That is odd, since I can see the method there:


<!--- BeanFactory --->
<cffunction name="setBeanFactory" access="public" output="false" returntype="void" hint="I set a BeanFactory (Spring-interfaced IoC container) to inject into all created objects)." >
<cfargument name="factory" type="coldspring.beans.BeanFactory" required="true" />
<cfset variables.BeanFactory = arguments.factory />
<cfset getObjectFactory().setBeanFactory( arguments.factory )>
</cffunction>

And if I look at the object factory... 

  <!--- BeanFactory --->
  <cffunction name="setBeanFactory" access="public" output="false" returntype="void" hint="I set a BeanFactory (Spring-interfaced IoC container) to inject into all created objects)." >
  <cfargument name="beanFactory" type="any" _type="any" required="true" />
  <cfset variables.BeanFactory = arguments.beanFactory />
  </cffunction>


So all I can think of is that maybe the object factory isnt being set on init? But it seems to be created natively.. 

<cffunction name="init" access="public" hint="I configure this object factory" returntype="any" _returntype="reactorFactory">
<cfargument name="configuration" hint="I am either a relative or absolute path to the config XML file or an instance of a reactor.config.config component" required="yes" type="any" _type="any" />
<cfargument name="BeanFactory" hint="I am an IOC beanfactory that you can inject to inject objects into your records and gateways" required="false" type="coldspring.beans.BeanFactory">

<!--- if the config was not passed in, load the XML file --->
<cfif NOT IsObject(arguments.configuration)>
<cfset arguments.configuration = CreateObject("Component", "reactor.config.config").init(arguments.configuration) />
</cfif>


<!--- pass the configuration into the objectFactory --->
<cfset setObjectFactory(CreateObject("Component", "reactor.core.objectFactory").init(arguments.configuration, this)) />


<!--- If we have passed in a BeanFactory set it for the following method --->

<cfif StructKeyExists(arguments,"factory") AND isObject(arguments.factory)>
<cfset variables.BeanFactory = arguments.factory>
<cfset getObjectFactory().setBeanFactory(arguments.factory) />
<cfreturn this />
</cfif>


<!--- give the objectfactory the beanfactory if it is injected --->
<cfset getObjectFactory().setBeanFactory(getBeanFactory()) />


<cfreturn this />
</cffunction>
Try aborting on reactorFactory.cfc at line 135 and see if you do indeed have an objectFactory?

I found a problem that it was trying to getObjectFactory in the init, but it wouldn't have been set. 

MD
--

You received this message because you are subscribed to the Google Groups "Reactor" group.
To post to this group, send email to reacto...@googlegroups.com.
To unsubscribe from this group, send email to reactor-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/reactor-users?hl=en.



Mark Drew
Railo Technologies UK
Professional Open Source
skype: mark_railo
+44 7971 85  22 96



Chuck Savage

unread,
Dec 3, 2009, 5:12:05 PM12/3/09
to reacto...@googlegroups.com
Can you tell me what files you are looking for these methods so I can check to be sure I've uploaded(put) them to the server properly?  I put the /reactor folder, otherwise I may have missed something.  The docs said I only needed the /reactor, /documentation, and /reactorSamples, and I'd guess I only need to put the /reactor directory.

Chuck Savage

unread,
Dec 3, 2009, 5:36:02 PM12/3/09
to reacto...@googlegroups.com
I did indeed to a

<cfdump var="#getObjectFactory()#" />
<cfabort>

Just before the
<cfset getObjectFactory().setBeanFactory( arguments.factory )>

It outputs a zero.

So no object...


Chuck Savage

unread,
Dec 3, 2009, 5:45:15 PM12/3/09
to reacto...@googlegroups.com
More info if it helps

My cold-spring config file has these declared...

    <alias alias="ormAdapter" name="ormAdapter.Reactor" />
    <alias alias="ormService" name="ormService.Reactor" />
    <bean id="reactorConfiguration" class="reactor.config.config">
        <constructor-arg name="pathToConfigXml">
        <value>/mg/config/Reactor.xml.cfm</value>
    </constructor-arg>
        <property name="project"><value>mg</value></property>
        <property name="dsn"><value>main</value></property>
        <property name="type"><value>mysql</value></property>
        <property name="mapping"><value>/mg/reactorData</value></property>
        <property name="mode"><value>development</value></property>
    </bean>

My Reactor.xml.cfm config file

I had it just <reactor></reactor> but I chanced copying the config info, it didn't help.

<reactor>
    <config>
        <project value="mg" />
        <dsn value="main" />
        <type value="mysql" />
        <mapping value="/mg/reactorData" />
        <mode value="development" />
        <!-- These config values are not required -->
        <!-- <username value="" />
        <password value="" /> -->
    </config>

    <objects />
</reactor>

Mark Drew

unread,
Dec 3, 2009, 5:52:40 PM12/3/09
to reacto...@googlegroups.com
I dont think you need the config in there if you are passing it as a
parameters too...

MD

Chuck Savage

unread,
Dec 3, 2009, 5:58:50 PM12/3/09
to reacto...@googlegroups.com
Ok, good to know.

I've puzzled out enough to find out that reactorFactory's Init() is never called.  Since I set a variable.value there and call it from the same method setBeanFactory(), and it is undefined.  Its progress I suppose.

Chuck Savage

unread,
Dec 3, 2009, 6:14:24 PM12/3/09
to reacto...@googlegroups.com
I found the problem, I don't know the solution...

In ColdSpring\beans\DefaultXmlBeanFactory.cfc starting at line: 866

It would call Init() if beanDef.getFactoryBean() eq "", but since it is an object, it doesn't call it.  So when the call in the <cfelseif> further down (line 902), it throws in setBeanFactory in reactorFactory because init() is never called.

What's the solution?  Do I have an old/new version of ColdSpring that isn't like what reactor's reactorFactory was configured with?

                    <cfif structKeyExists(md, "functions")>
                        <!--- we need to call init method if it exists --->
                        <cfloop from="1" to="#arraylen(md.functions)#" index="functionIndex">
                            <cfif md.functions[functionIndex].name eq "init"
                                    and beanDef.getFactoryBean() eq "">
                               
                                <cftry>
                                <cfinvoke component="#beanInstance#" method="init">
                                    <!--- loop over any bean constructor-args and pass them into the init() --->
                                    <cfloop collection="#argDefs#" item="arg">
                                        <cfset argType = argDefs[arg].getType() />
                                        <cfif argType eq "value">
                                            <cfinvokeargument name="#argDefs[arg].getArgumentName()#"
                                                              value="#argDefs[arg].getValue()#"/>
                                        <cfelseif argType eq "list" or argType eq "map">
                                            <cfinvokeargument name="#argDefs[arg].getArgumentName()#"
                                                              value="#constructComplexProperty(argDefs[arg].getValue(),argDefs[arg].getType(), localBeanCache)#"/>
                                        <cfelseif argType eq "ref" or argType eq "bean">
                                            <cfinvokeargument name="#argDefs[arg].getArgumentName()#"
                                                              value="#getBean(argDefs[arg].getValue())#"/>
                                        </cfif>                                             
                                    </cfloop>
                                </cfinvoke>
                               
                                <cfcatch type="any">
                                    <cfthrow type="coldspring.beanCreationException"
                                        message="Bean creation exception during init() of #beanDef.getBeanClass()#"
                                        detail="#cfcatch.message#:#cfcatch.detail#">
                                </cfcatch>
                            </cftry>
                           
                            <cfelseif md.functions[functionIndex].name eq "setBeanFactory"
                                      and arraylen(md.functions[functionIndex].parameters) eq 1
                                      and structKeyExists(md.functions[functionIndex].parameters[1],"type")
                                      and md.functions[functionIndex].parameters[1].type eq "coldspring.beans.BeanFactory">
                                <!--- call setBeanFactory() if it exists and is a beanFactory --->
                                <cfset beanInstance.setBeanFactory(beanDef.getBeanFactory()) />   
                               
                            </cfif>
                        </cfloop>
                    </cfif>               

Mark Drew

unread,
Dec 3, 2009, 6:12:42 PM12/3/09
to reacto...@googlegroups.com
That is what I found out, I need to check my local copy to make sure
all is in sync since I got round that problem by adding a couple of
methods.

Chuck Savage

unread,
Dec 4, 2009, 1:42:35 PM12/4/09
to reacto...@googlegroups.com
I found the problem, it wasn't what I first thought.

The problem is that at that place in DefaultXmlBeanFactory.cfc it is looping over the method array of functions to the beanInstance class.  If Init() is after setFactoryBean() in the array it isn't called ahead of time.

I created a function in DefaultXmlBeanFactory called pushInit() that if init method exists in the class, it pushes it to the top of the array to be sure its called first.

<cffunction name="pushInit" access="private" output="false" returntype="array" hint="We parse array, and if 'init' exists, we push it to front of array">
  <cfargument name="functions" type="array" required="yes" hint="we are the array to parse">
  <cfloop from="1" to="#arraylen(functions)#" index="functionIndex">
    <!--- check for method init in array --->
    <cfif functions[functionIndex].name eq "init">
      <!--- found, if first no sorting required and just return --->
      <cfif 1 eq functionIndex><cfreturn functions></cfif>
      <cfset arraySwap(functions, 1, functionIndex)>
      <cfreturn functions>
    </cfif>
  </cfloop>
  <!--- init doesn't exist --->
  <cfreturn functions>
</cffunction>


This is inserted at line 867
<!--- sort array to be sure init method is always first checked (if it exists) --->
<cfset md.functions = pushInit(md.functions)>

I'm cross posting this to the ColdSpring user group

Reply all
Reply to author
Forward
0 new messages