Skip to main content
nikos101
Inspiring
June 22, 2012
Answered

ussue with application.cfc in flash remoting

  • June 22, 2012
  • 1 reply
  • 6435 views

<cfcomponent

    output="false"

    hint="I define the application settings and event handlers.">

hi, im using flash remoting to call cfcs and I want to use this application.cfc to determine the environment (the APPLICATION.environment defines a DSN used in the cfcs flash calls).

however everytime I call a cfc with this app.cfc I get a error from CF which I can't debug because CF builder is uselss for connecting to debuggers. Any ideas?

    <!--- Define the application. --->

    <cfset this.name = hash( getCurrentTemplatePath() ) />

    <cfset this.applicationTimeout = createTimeSpan( 0, 0, 1, 0 ) />

   

<cffunction name="onApplicationStart" output="false">

     

      <cfset path = cgi.SERVER_NAME & cgi.SCRIPT_NAME>

     

     <cfset serverAnd2Dirs = reFind("([\w-]+/\w+/\w+)",path,0,true)>

    <cfset match = mid(path, serverAnd2Dirs.pos[1], serverAnd2Dirs.len[1])   >

   

   <cfset var identifier = createObject("component","DomainEnvironmentIdentifier").init(match)>

    <cfset var environment = createObject("component","Environment" ).init(expandPath('/')&"coldfusion\config\environments.xml.cfm")>

      <cfset environment.use( identifier.currentEnvironment() )>

    <cfset APPLICATION.environment = this.environment>

   

    

</cffunction>

</cfcomponent>

This topic has been closed for replies.
Correct answer Adam Cameron.

ah I thought application.var was used to access global vars

anyway I tried

<cfdump var="#this.name#" >

Element NAME is undefined in THIS.


No.  The application scope is used to access application-scoped variables.

I think you need to read up on how scopes work in CF.  Read this entire section of the docs:

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7ff2.html

I can't guess where in your code you put the CFDUMP, so I can't really comment on the rest of it.

--

Adam

1 reply

Inspiring
June 22, 2012

Well you can debug it via a CFM file instead of from Flash (or using the CFB debugger, which I agree is a bit hit and miss.  Mostly miss).  And you could look at the error logs to see what the errors are...

--

Adam

nikos101
nikos101Author
Inspiring
June 22, 2012

why does adobe release this CFB2 debugger nonsense ?!

If I call a cfc from flex this is the error:

"Error","jrpp-65","06/22/12","13:44:05",,"Event handler exception. An exception occurred while invoking an event handler method from Application.cfc. The method name is: onApplicationStart."

if I call from a cfm:

"Error","jrpp-65","06/22/12","13:41:19","2EC8204583ADAF402268D67FCB11BF48","Element ENVIRONMENT is undefined in THIS. The specific sequence of files included or processed is: C:\Inetpub\wwwroot\coldfusion\tests\testEnvironmentName.cfm, line: 24 "

code in cfm=>

<cfdump var="#application.environment#" >

Inspiring
June 22, 2012

Right.  And what does the error message say:

Element ENVIRONMENT is undefined in THIS. The specific sequence of files included or processed is: C:\Inetpub\wwwroot\coldfusion\tests\testEnvironmentName.cfm, line: 24

Does that not give you a pretty big hint as to what's wrong?  Read the error, and ask youirself "OK, what does that mean?  What's CF telling me here?"

It's also telling you the exact line that has the problem on it.

--

Adam