• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ussue with application.cfc in flash remoting

Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

<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>

TOPICS
Flash integration

Views

5.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 22, 2012 Jun 22, 2012

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

Votes

Translate

Translate
LEGEND ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

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#" >

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

I see that, but I don't see what is wrong with my code:

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

because that var should be defined in app.cfc?

<cfset APPLICATION.environment = this.environment>

btw can you offer any tips on getting this horrible debugger to work better?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

The only reference to this.environment is in that statement you just quoted.  So it doesn't exist.  Nowhere in your Application.cfc (as quoted in your earlier post) do you create that variables.  That's why CF is telling you it doesn't exist.  Because it dun't 😉

And - no - I could not get the CFB debugger working in any way other than very basic test cases (and ti wasn't very robust when I could get it working).  It seems you need to have your source code location, site structure and CFB project set up in a very unlikely-to-be-how-one-needs-it-to-be sort of way for it to work.  And I'm not going to restructure our application justt o get some shoddy CFB functionality to work.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

these debugger issues just force users to move to things like .Net

anyway, even if I do

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

I get the error

Element NAME is undefined in APPLICATION.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

Well you're not setting that either.  Why would you expect it to exist?  Do you understand that THIS.someVar != APPLICATION.someVar != someVar.  They are completely different things.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

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

anyway I tried

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

Element NAME is undefined in THIS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

sweet mate:

this is what I had to do

   <cfset application.env = environment >

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

Yup!

Make sure you read those docs though, eh?  It'll help clear up a lot of mysteries like this.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 22, 2012 Jun 22, 2012

Copy link to clipboard

Copied

hopefully i wont need to read much more:), .Net is a dream with c#

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 25, 2012 Jun 25, 2012

Copy link to clipboard

Copied

the code works fine for coldfusion apps, but when calling from flex via remote object I get this error now:

Unable to invoke CFC - Event handler exception.An exception occurred while invoking an event handler method from Application.cfc. The method name is: onApplicationStart.

could this be the problem:

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

     

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2012 Jun 25, 2012

Copy link to clipboard

Copied

I couldn't comment on how Flex calls might impact the presence of those variables.

What do the error logs say?  They're likely to have more info.

What other troubleshooting steps have you yourself come up with?  How have you tried to debug this?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

all the log says is

"Error","jrpp-122","06/25/12","15:12:55",,"Event handler exception. An exception occurred while invoking an event handler method from Application.cfc. The method name is: onApplicationStart."

Debugger broken as usual.

I've narrowed down my error to this in app.cfc because the match is failing on a regex because I didnt realise flex requests always set this to the flex gateway

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

I need to look at the file paths instead of these vars

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I'm trying to get Cf to know the location of the actual cfc I'm calling from flex but I can't get anything other than stuff like this:

c:\\inetpub\\wwwroot\\flex2gateway

basically the problem im having now is there are no vars in CGI in CF that let me know the directory of the current cfc being called. which is a problem because my cf app needs to behave differently based on its location of the server

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I've got the app.cfc working now:

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

     

..

    <cfset application.env = environment >

   

    

</cffunction>

however when I return this var to flex for testing it, it is empty in the flex debug

<cffunction name="getCurrentDatasourceBasedOnEnvironment" access="remote" returntype="any" >
   
    <cfreturn application.env>
</cffunction>

testing here in flex:

private function onResult2(event:ResultEvent, passthroughData:Object):void {

           

//should have a object

                 trace(event.result);

        }

perhaps the cfc is not getting the object env instatiated quickly enough on teh CF side?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

I'm trying to get Cf to know the location of the actual cfc I'm calling from flex but I can't get anything other than stuff like this:

c:\\inetpub\\wwwroot\\flex2gateway

How are you getting that?

It'd be a lot easier to help you if you explain what you're doing (code) what the results are (as per above), and how that differs from your expectation.

You could try getBaseTemplatePath().  This works for me when being called remotely from a browser, eg:

<!--- Application.cfc --->

<cfcomponent>

 

          <cffunction name="onApplicationStart">

                    <cfdump var="#getBaseTemplatePath()#">

                    <cfabort>

          </cffunction>

 

</cfcomponent>

<!--- C.cfc --->

<cfcomponent>

 

          <cffunction name="f" access="remote">

                    <cfreturn "Hello World">

          </cffunction>

</cfcomponent>

Browsing to:

http://www.scribble.local/cf/cfcs/app/whichFile/C.cfc?method=f

I dunno if the contortions FLex goes to will mess with that, but what I see is:

C:\WebSites\scribble\cf\cfcs\app\whichFile\C.cfc

Which is correct.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

LATEST

that should work for me too,

what I'm trying to do is pass this application.env to flex so I can check the env variable is set up correctly, it appears in teh flex result event as an empty object

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

     

      <cfset path = cgi.HTTP_REFERER>

     

     <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('/')&"flex\coldfusion\config\environments.xml.cfm")>

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

    <cfset application.env = environment >

   

    

</cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation