I can hit the proxy directly and it works.
When I hit the same proxy via Flex, I'm told
"Sorry, a ColdSpring BeanFactory named sharedBeanFactory was not found
in application scope. Please make sure your bean factory is properly
loaded. Perhapse your main application is not running?"
I am having a hard time troubleshooting this, but here are some
details, in the hopes that someone else can tell me what's going on.
I've modified the proxy to give me some debugging output. Note the
application scope variable list in output 1 and 2 below
1. Output from modded proxy when run directly
2. Output from modded proxy when run via Flex
3. Modded proxy itself
################# 1. Output from modded proxy when run directly
#################
=========== setup starting dump==========
wwwroot,components,sharedbeanfactory
===========setup ending dump==========
=========== setup ending dump2==========
===========callMethod starting dump==========
wwwroot,components,sharedbeanfactory
===========callMethod starting else dump==========
################# 2. Output from modded proxy when run via Flex
#################
=========== setup starting dump==========
wwwroot,components,sharedbeanfactory
===========setup ending dump==========
12/17 23:42:41 Error [jrpp-2] - Sorry, a ColdSpring BeanFactory named
sharedBeanFactory was not found in application scope. Please make sure
your bean factory is properly loaded. Perhapse your main application
is not running?
[Flex] Exception when invoking service: remoting-service
with message: Flex Message (flex.messaging.messages.RemotingMessage)
operation = getStates
clientId = EEC329D6-950A-5261-CA26-CE97622C7E3F
destination = ColdFusion
messageId = 8118B0E1-E5C6-F802-E595-4866DF594E67
timestamp = 1229575348325
timeToLive = 1229575348325
body = null
hdr(DSId) = EEC328E7-5309-AA60-C6AA-1B3978F84021
hdr(DSEndpoint) = my-cfamf
exception: flex.messaging.MessageException: Unable to invoke CFC -
Sorry, a ColdSpring BeanFactory named sharedBeanFactory was not found
in application scope. Please make sure your bean factory is properly
loaded. Perhapse your main application is not running?.
[Flex] Error handling message: flex.messaging.MessageException: Unable
to invoke CFC - Sorry, a ColdSpring BeanFactory named
sharedBeanFactory was not found in application scope. Please make sure
your bean factory is properly loaded. Perhapse your main application
is not running?.
incomingMessage: Flex Message (flex.messaging.messages.RemotingMessage)
operation = getStates
clientId = EEC329D6-950A-5261-CA26-CE97622C7E3F
destination = ColdFusion
messageId = 8118B0E1-E5C6-F802-E595-4866DF594E67
timestamp = 1229575348325
timeToLive = 1229575348325
body = null
hdr(DSId) = EEC328E7-5309-AA60-C6AA-1B3978F84021
hdr(DSEndpoint) = my-cfamf
errorReply: Flex Message (flex.messaging.messages.ErrorMessage)
clientId = EEC329D6-950A-5261-CA26-CE97622C7E3F
correlationId = 8118B0E1-E5C6-F802-E595-4866DF594E67
destination = ColdFusion
messageId = EEC3A5F5-7C08-A8B0-44AC-5C10F772BB86
timestamp = 1229575361340
timeToLive = 0
body = null
code =
message = Unable to invoke CFC - Sorry, a ColdSpring BeanFactory
named sharedBeanFactory was not found in application scope. Please
make sure your bean factory is properly loaded. Perhapse your main
application is not running?
details =
rootCause = null
body = null
extendedData = {stacktrace=
[
coldfusion.tagext.lang.ThrowTag.doStartTag(ThrowTag.java:124),
coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2661),
cfimsAddressService2ecfc1741861053$funcSETUP.runFunction(/var/www/apps/childwelfare/wwwroot/cfc/imsAddressService.cfc:106),
coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:418),
coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:360),
coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:324),
coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:59),
coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:277),
coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:192),
coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2471),
cfimsAddressService2ecfc1741861053.runPage(/var/www/apps/childwelfare/wwwroot/cfc/imsAddressService.cfc:56),
coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196),
coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47),
coldfusion.runtime.TemplateProxyFactory.resolveComponentHelper(TemplateProxyFactory.java:488),
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:225),
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:157),
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:147),
coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:131),
coldfusion.runtime.TemplateProxyFactory.resolveFile(TemplateProxyFactory.java:90),
coldfusion.runtime.TemplateProxyFactory.resolveFile(TemplateProxyFactory.java:81),
coldfusion.flash.filter.CFCInvokeFilter.invoke(CFCInvokeFilter.java:104),
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279),
coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40),
coldfusion.flash.filter.CFCInvokeDebugFilter.invoke(CFCInvokeDebugFilter.java:54),
coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27),
coldfusion.flash.filter.CFCInvokePathFilter.invoke(CFCInvokePathFilter.java:70),
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28),
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38),
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22),
coldfusion.flash.messaging.ColdFusionAdapter.invoke(ColdFusionAdapter.java:223),
flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:173),
flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1165),
flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:757),
flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:117),
flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158),
flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:48),
flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67),
flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:145),
flex.messaging.endpoints.AMFEndpoint.service(AMFEndpoint.java:122),
flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:438),
coldfusion.flex.ColdFusionMessageBrokerServlet.service(ColdFusionMessageBrokerServlet.java:50),
javax.servlet.http.HttpServlet.service(HttpServlet.java:853),
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89),
jrun.servlet.FilterChain.doFilter(FilterChain.java:86),
coldfusion.filter.FlashRequestControlFilter.doFilter(FlashRequestControlFilter.java:71),
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46),
jrun.servlet.FilterChain.doFilter(FilterChain.java:94),
jrun.servlet.FilterChain.service(FilterChain.java:101),
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106),
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42),
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286),
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543),
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203),
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428),
jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
], type=coldspring.remoting.ApplicationContextError, rootcause=null}
################# 3. Modded proxy itself #################
<!---
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: imsAddressService.cfc 26563 2008-12-18 04:34:00Z developers $
$Log: RemoteProxyBean.cfc,v $
Revision 1.8 2008/03/07 02:25:04 pjf
Var'ed and scope variables caught by a var scope checker
Revision 1.7 2007/09/11 11:41:52 scottc
Fixed error setting bean factory in the proper scope, moved
initialization into setup method in RemoteProxyBean
Revision 1.6 2007/01/01 17:41:36 scottc
added support for <alias name="fromName" alias="toName"/> tag
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="imsAddressService"
displayname="imsAddressService:RemoteProxyBean"
hint="Abstract Base Class for Aop Based Remote Proxy Beans"
output="false">
<cfset variables.proxyId = CreateUUId() />
<cfset variables.beanFactoryName = "sharedBeanFactory" />
<cfset variables.beanFactoryScope = "" />
<cfset variables.constructed = false />
<cfset setup() />
<cffunction name="setup" access="public" returntype="void">
<cfset var bfUtils = 0 />
<cfset var bf = 0 />
<cfset var error = false />
<cfset var remoteFactory = "" />
<!--- I want to make sure that the proxy id really exists --->
<cfif not StructKeyExists(variables, "proxyId")>
<cfset variables.proxyId = CreateUUId() />
</cfif>
<cfdump var="=========== setup starting dump==========" output="console">
<cfdump var=#structKeyList(application)# output="console" label="application">
<cflock name="RemoteProxyBean.#variables.proxyId#.Setup"
type="readonly" timeout="5">
<cfif not StructKeyExists(variables, "constructed") or not
variables.constructed>
<!--- it looks like there is an issue with setting up the
variables scope in a static initializer
with remote methods, so we will make sure things are set up --->
<cfif not StructKeyExists(variables, "constructed")>
<cfset variables.beanFactoryName = "sharedBeanFactory" />
<cfset variables.beanFactoryScope = "" />
<cfset variables.constructed = false />
</cfif>
<!--- make sure scope is setup (could have been set to '', meaning
application, default) --->
<cfif not len(variables.beanFactoryScope)>
<cfset variables.beanFactoryScope = 'application' />
</cfif>
<cftry>
<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("&testServiceRemote") />
<cfset variables.target = bf.getBean("testServiceRemote") />
<cfset variables.adviceChains = remoteFactory.getProxyAdviceChains() />
<cfset variables.constructed = true />
<cfcatch>
<cfset error = true />
</cfcatch>
</cftry>
</cfif>
</cflock>
<cfdump var="===========setup ending dump==========" output="console">
<cfif error>
<cfthrow type="coldspring.remoting.ApplicationContextError"
message="Sorry, a ColdSpring BeanFactory named
#variables.beanFactoryName# was not found in
#variables.beanFactoryScope# scope. Please make sure your bean factory
is properly loaded. Perhapse your main application is not running?" />
</cfif>
<cfdump var="=========== setup ending dump2==========" output="console">
</cffunction>
<cffunction name="callMethod" access="private" 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 />
<cfdump var="===========callMethod starting dump==========" output="console">
<cfdump var=#structKeyList(application)# output="console" label="application">
<!--- make sure setup is called --->
<cfif not StructKeyExists(variables, "constructed") or not
variables.constructed>
<cfset setup() />
</cfif>
<!--- if an advice chain was created for this method, retrieve a
methodInvocation chain from it and proceed --->
<cfif StructKeyExists(variables.adviceChains, arguments.methodName)>
<cfdump var="===========callMethod starting if dump=========="
output="console">
<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>
<cfdump var="===========callMethod starting else dump=========="
output="console">
<!--- 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>
<cfdump var="===========callMethod ending dump==========" output="console">
</cffunction>
<cffunction name="getStates" access="remote" returntype="any" output="false" >
<cfset var rtn = callMethod('getStates', arguments) />
<cfif isDefined('rtn')><cfreturn rtn /></cfif>
</cffunction>
</cfcomponent>