Found the problem - the service-config.xml file had to be modified to allow
access to ColdFusion mappings. See <use-mappings>true</use-mappings> was set to
false previously.
<destination id="SecureColdFusion">
<channels>
<channel ref="my-secureamf"/>
</channels>
<properties>
<source>*</source>
<!-- define the resolution rules and access level of the
cfc being invoked -->
<access>
<!-- Use the ColdFusion mappings to find CFCs, by
default only CFC files under your webroot can be found. -->
<use-mappings>true</use-mappings>
<!-- allow "public and remote" or just "remote" methods
to be invoked -->
<method-access-level>remote</method-access-level>
</access>
<property-case>
<!-- cfc property names -->
<force-cfc-lowercase>false</force-cfc-lowercase>
<!-- Query column names -->
<force-query-lowercase>false</force-query-lowercase>
<!-- struct keys -->
<force-struct-lowercase>false</force-struct-lowercase>
</property-case>
</properties>
</destination>
________________________________
From: Brian Kotek [mailto:[EMAIL PROTECTED]
Sent: Monday, November 19, 2007 8:30 AM
To: [email protected]
Subject: [coldspring-dev] Remote Facade Problem with Flex Remoting
Is the Remote Facade generated into a directory that has access to the
application scope where the ColdSpring bean factory exists? And, are you sure
it is named "application.beanFactory"?
On Nov 19, 2007 11:01 AM, Temme, Gary D <[EMAIL PROTECTED]> wrote:
We are using the Coldspring generated remote facades and are getting
strange results. They appear to work fine when called from a .CFM page
directly, but when we call them from Flex using the RemoteObject, we get an
error. The .SWF is running inside a .CFM page.
I have seen in the coldspring mail archive, some discussion about
strange behavior when calling from flex, but could not find a fix
-------------- QUESTION
----------------------------------------------------------------------------------------------------------------------------
Has anyone seen this behavior or had success correcting it? It almost
seems as if the remoting call cannot find the application scope and the
coldspring components inside the application scope.
--------------------- BACKGROUND
---------------------------------------------------------------------------------------------
Steps to de-bug thusfar are as follows:
1) original message displayed to the client:
Sorry, a ColdSpring BeanFactory named serviceFactory was not found in
application scope. Please make sure your bean factory is properly loaded.
Perhapse your main application is not running?
2) I notice that this message is returned by the coldspring generated
remote façade, so I removed the cftry/cfcatch stements from the generated
façade. The next error that comes back is: "Could not find the ColdFusion
Component coldspring.beans.util.BeanFactoryUtils."
3) When I run the code that is inside the generated façade from a
test.cfm as seen below, the test page works fine (note "var" remved from cfset
beacause not inside a function).
<cfset variables.beanFactoryName = "serviceFactory" />
<cfset variables.beanFactoryScope = "" />
<cfset bfUtils = 0 />
<cfset bf = 0 />
<!--- make sure scope is setup (could have been set to
'', meaning application, default) --->
<cfif not len(variables.beanFactoryScope)>
<cfset variables.beanFactoryScope =
'application' />
</cfif>
<cfset bfUtils =
createObject("component","coldspring.beans.util.BeanFactoryUtils").init()/>
<cfif not len(variables.beanFactoryName)>
<cfset bf =
bfUtils.getDefaultFactory(variables.beanFactoryScope) />
<cfelse>
<cfset bf =
bfUtils.getNamedFactory(variables.beanFactoryScope, variables.beanFactoryName)
/>
</cfif>
<cfset remoteFactory =
bf.getBean("&CompanyService_remote") />
<cfdump var="#remoteFactory#">
---------------------- CODE BELOW
----------------------------------------------------------------------------------------------------------------------
This is our RemoteObject call:
<mx:RemoteObject id="RemoteCompanyService"
destination="SecureColdFusion" showBusyCursor="true"
source="remote.RemoteCompanyService ">
<mx:method name="getCompany"/>
<mx:method name="getCompanys"/>
<mx:method name="saveCompany"/>
<mx:method name="deleteCompany"/>
</mx:RemoteObject>
This is the remote façade generated by Coldspring (with cftry and
cfcatch removed from the setup method for de-bugging)
<!---
Copyright (c) 2005, Chris Scott, David Ross, Kurt Wiersma, Sean
Corfield
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.
$Id: RemoteProxyBean.cfc,v 1.5 2006/06/25 13:22:43 rossd Exp $
$Log: RemoteProxyBean.cfc,v $
Revision 1.5 2006/06/25 13:22:43 rossd
removing debug code
Revision 1.4 2006/04/04 03:51:27 simb
removed duplicate local var bfUtils
Revision 1.3 2006/01/28 21:44:13 scottc
Another slight tweek, everything refers to beanFactory, not context
Revision 1.2 2006/01/28 21:39:57 scottc
Shoot, the RemoteProxyBean was looking for an applicationContext
instead of a bean factory. Updated to look for a beanFactory, but I
need to test!
Revision 1.1 2006/01/13 15:00:12 scottc
CSP-38 - First pass at RemoteProxyBean, creating remote services for
CS managed seriveces through AOP
--->
<cfcomponent name="RemoteCompanyService"
displayname="RemoteCompanyService:RemoteProxyBean"
hint="Abstract Base Class for Aop Based Remote
Proxy Beans"
output="false">
<cfset variables.beanFactoryName = "serviceFactory" />
<cfset variables.beanFactoryScope = "" />
<cfset setup() />
<cffunction name="setup" access="public" returntype="void">
<cfset var bfUtils = 0 />
<cfset var bf = 0 />
<!--- make sure scope is setup (could have been set to
'', meaning application, default) --->
<cfif not len(variables.beanFactoryScope)>
<cfset variables.beanFactoryScope =
'application' />
</cfif>
<cfset bfUtils = createObject("component","
coldspring.beans.util.BeanFactoryUtils").init()/>
<cfif not len(variables.beanFactoryName)>
<cfset bf =
bfUtils.getDefaultFactory(variables.beanFactoryScope ) />
<cfelse>
<cfset bf =
bfUtils.getNamedFactory(variables.beanFactoryScope, variables.beanFactoryName)
/>
</cfif>
<cfset remoteFactory =
bf.getBean("&CompanyService_remote") />
<cfset variables.target =
bf.getBean("CompanyService_remote") />
<cfset variables.adviceChains =
remoteFactory.getProxyAdviceChains() />
</cffunction>
<cffunction name="callMethod" access="public" returntype="any">
<cfargument name="methodName" type="string"
required="true" />
<cfargument name="args" type="struct" required="true" />
<cfset var adviceChain = 0 />
<cfset var methodInvocation = 0 />
<cfset var rtn = 0 />
<cfset var method = 0 />
<!--- if an advice chain was created for this method,
retrieve a methodInvocation chain from it and proceed --->
<cfif StructKeyExists(variables.adviceChains,
arguments.methodName)>
<cfset method =
CreateObject('component','coldspring.aop.Method').init(variables.target ,
arguments.methodName,
arguments.args) />
<cfset adviceChain =
variables.adviceChains[arguments.methodName] />
<cfset methodInvocation =
adviceChain.getMethodInvocation (method, arguments.args, variables.target) />
<cfreturn methodInvocation.proceed() />
<cfelse>
<!--- if there's no advice chains to execute,
just call the method --->
<cfinvoke component="#variables.target#"
method="#arguments.methodName#"
argumentcollection="#arguments.args#"
returnvariable="rtn">
</cfinvoke>
<cfif isDefined('rtn')>
<cfreturn rtn />
</cfif>
</cfif>
</cffunction>
<cffunction name="getCompanys" access="remote" returntype="any"
output="false" >
<cfargument name="companyID"
type="numeric"
required="false" />
<cfargument name="companyName"
type="string" required="false" />
<cfargument name="CCID" type="string"
required="false" />
<cfargument name="createdByBems"
type="numeric" required="false" />
<cfargument name="lastModifiedDate"
type="date" required="false" />
<cfargument name="comments"
type="string" required="false" />
<cfargument name="activeIndicator"
type="boolean" required="false" />
<cfset var rtn =
callMethod('getCompanys', arguments) />
<cfif isDefined('rtn')><cfreturn rtn
/></cfif>
</cffunction>
<cffunction name="createCompany" access="remote" returntype="any"
output="false" >
<cfargument
name="companyID" type="numeric" required="true" />
<cfargument name="companyName" type="string" required="false" />
<cfargument
name="CCID" type="string" required="false" />
<cfargument name="createdByBems" type="numeric" required="false" />
<cfargument
name="lastModifiedDate" type="date" required="false" />
<cfargument name="comments" type="string" required="false" />
<cfargument
name="activeIndicator" type="boolean" required="false" />
<cfset var rtn = callMethod('createCompany', arguments) />
<cfif
isDefined('rtn')><cfreturn rtn /></cfif>
</cffunction>
<cffunction name="deleteCompany" access="remote" returntype="any"
output="false"
>
<cfargument name="companyID" type="numeric"
required="true" />
<cfset var rtn = callMethod('deleteCompany', arguments)
/>
<cfif
isDefined('rtn')><cfreturn rtn /></cfif>
</cffunction>
<cffunction name="saveCompany" access="remote" returntype="any"
output="false" >
<cfargument name="Company" type="mbfnetperf.services.companies.Company"
required="true" />
<cfset var rtn = callMethod('saveCompany',
arguments) />
<cfif isDefined('rtn')><cfreturn rtn /></cfif>
</cffunction>
<cffunction name="getCompany" access="remote"
returntype="any" output="false" >
<cfargument name="companyID" type="numeric" required="true" />
<cfset var rtn =
callMethod('getCompany', arguments) />
<cfif isDefined('rtn')><cfreturn rtn /></cfif>
</cffunction>
</cfcomponent>
Gary Temme
Cell - 714 475 9338