Flex/Coldspring Error?

Over this past week, I started using Coldspring in an application that I have been building at work; I love the fact that I don't have to call createobject in every function, and it should save me mountains of time once I become used to writing the coldspring config files.  However,  I ran into a small problem yesterday that I haven't been able to figure out.

The problem occurs when I call remote objects in Flex, and the onApplicationStart method hasn't previously been called from ColdFusion.  If I run a test page that calls the cfcs, the results are returned without a problem, and I can actually run the application in Flex just fine after the onApplicationStart method has been called once from ColdFusion.  Has anyone else run into this problem?  I can't seem to find any useful information after googling this morning.

Error:

Event handler exception. An exception occurred when invoking a event handler method from Application.cfc. The method name is: onApplicationStart. 

<cffunction name="onApplicationStart" returnType="boolean" output="false">
   
        <cfset var properties = structNew() />
        <cfset coldspringConfig = 'coldspring.xml' /> 
        <cfset application.beanFactory=
createObject('component', 'coldspring.beans.DefaultXmlBeanFactory').init() />

<cfset properties.dsn = "NearMiss" />
  <cfset                                                                                                                                                     application.beanFactory=
CreateObject('component', 'coldspring.beans.DefaultXmlBeanFactory').
init(defaultProperties=properties) />
        <cfset application.beanFactory.loadBeans(coldspringConfig) />
       
        <cfreturn true>
    </cffunction>

7 responses so far ↓

Steven Brownlee - Sep 16, 2009 at 1:02 PM

It's not so much a problem as simply a requirement. You need to hit any CFM page in your application that uses ColdSpring before the beans can be created.

What we've done is have our Flex clients loaded inside the index.cfm page of the application itself so that all CF-related startup procedure take place before the Flex client is loaded into the browser.

Stephen Weyrick - Sep 16, 2009 at 1:08 PM

@Steven

So you just redirect the client to the Flex Application once they hit the index.cfm page?

Henry Ho - Sep 16, 2009 at 1:51 PM

I guess that's why CF9 has onServerStart().

Steven Brownlee - Sep 16, 2009 at 2:15 PM

No redirection needed, the <InvalidTag> tag for loading the movie is in the index.cfm page.

TJ Downes - Sep 16, 2009 at 3:01 PM

what he is saying is that the index.cfm page causes the onApplicationStart to execute, thereby your Flex requests, which occur after the index.cfm has loaded, will be able to take advantage of the variables loaded in during onApplicationStart

Stephen Weyrick - Sep 16, 2009 at 3:23 PM

@Steven
Thanks for your advice. I am going to try this when I get a chance.

@Henry
Yes, I hear that the onServerStart() method is a nice little feature in CF9.

@TJ
Ya, I understood that much. I was just hoping there might be a work around, so I didn't have to load an index.cfm page. In most of the flex apps I have built, I haven't used application variables. Is this same scenario true for all of the variables/objects loaded into the Application Scope?

Tom Chiverton - Sep 17, 2009 at 8:41 AM

We do the same thing, have the Flex app load from a .cfm page so that Application.cfc fires.
OnServerStart() is a possibility in CF9, but you could also introduce a call (via 'wget') to a .cfm page in your server restart script.

Leave a Comment