-
1. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 22, 2012 4:42 AM (in response to nikos101)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
-
2. Re: ussue with application.cfc in flash remoting
nikos101 Jun 22, 2012 5:47 AM (in response to Adam Cameron.)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#" >
-
3. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 22, 2012 5:57 AM (in response to nikos101)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
-
4. Re: ussue with application.cfc in flash remoting
nikos101 Jun 22, 2012 5:59 AM (in response to Adam Cameron.)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?
-
5. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 22, 2012 6:08 AM (in response to nikos101)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
-
6. Re: ussue with application.cfc in flash remoting
nikos101 Jun 22, 2012 6:44 AM (in response to Adam Cameron.)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.
-
7. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 22, 2012 6:46 AM (in response to nikos101)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
-
8. Re: ussue with application.cfc in flash remoting
nikos101 Jun 22, 2012 7:21 AM (in response to 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.
-
9. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 22, 2012 7:42 AM (in response to nikos101)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:
I can't guess where in your code you put the CFDUMP, so I can't really comment on the rest of it.
--
Adam
-
10. Re: ussue with application.cfc in flash remoting
nikos101 Jun 22, 2012 8:21 AM (in response to Adam Cameron.)sweet mate:
this is what I had to do
<cfset application.env = environment >
-
11. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 22, 2012 8:24 AM (in response to nikos101)Yup!
Make sure you read those docs though, eh? It'll help clear up a lot of mysteries like this.
--
Adam
-
12. Re: ussue with application.cfc in flash remoting
nikos101 Jun 22, 2012 9:32 AM (in response to Adam Cameron.)hopefully i wont need to read much more:), .Net is a dream with c#
-
13. Re: ussue with application.cfc in flash remoting
nikos101 Jun 25, 2012 7:44 AM (in response to nikos101)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>
-
14. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 25, 2012 7:52 AM (in response to nikos101)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 -
15. Re: ussue with application.cfc in flash remoting
nikos101 Jun 26, 2012 2:23 AM (in response to Adam Cameron.)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
-
16. Re: ussue with application.cfc in flash remoting
nikos101 Jun 26, 2012 2:45 AM (in response to nikos101)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
-
17. Re: ussue with application.cfc in flash remoting
nikos101 Jun 26, 2012 3:34 AM (in response to nikos101)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?
-
18. Re: ussue with application.cfc in flash remoting
Adam Cameron. Jun 26, 2012 3:40 AM (in response to nikos101)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
-
19. Re: ussue with application.cfc in flash remoting
nikos101 Jun 26, 2012 4:14 AM (in response to Adam Cameron.)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>


