So, I have an update to my very strange Application.cfc errors. I took the advice of some people and I tried moving the code into new files in new directories to see if it was a template caching issue. Now, I only have an Application.cfc, and index.cfm, and trace.txt files. The methods in the Application.cfc ONLY do a CFFile / Append to the trace.txt file so I can see if and when system events fire. The index.cfm ONLY dumps out the APPLICATION scope. There is no other code being run here, no other error handling.
Here is the updated Application.cfc
Launch code in new window » Download code as text file »
Here is the output that it produces:
OnApplicationStart
OnSessionStart
OnRequestStart
OnRequest
OnRequestEnd
OnSessionEnd : [ID - 43666] [TOKEN - 32723233]
OnError : [Event Handler Exception. - Expression] An exception occurred when invoking a event handler method from Application.cfc The method name is: onSessionEnd.
OnApplicationEnd : [NAME - App Event Testing 2]
OnError : [Event Handler Exception. - Expression] An exception occurred when invoking a event handler method from Application.cfc The method name is: onApplicationEnd.
As you can see, the OnSessionEnd and OnApplicationEnd methods are both firing and both can successfully reference their passed in scope arguments. However, both of them seem to fire an OnError even of type "Expression". I am not going to be too concerned with this, I suppose, as all the events ARE firing. I just wish I knew why error was firing as well.
Thanks for all your help and if any one sees what's going on, please let me know. Thanks!
Download Code Snippet ZIP File
Comments (7) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
Programmatically Deleting Scheduled Tasks In ColdFusion
PLEASE HELP! Why Is This Application.cfc Throwing Errors?
@Ben:
I'm going to take a guess and say it's because your CFRETURN tags are returning neither true or false. Try leaving the CFRETURN tags or setting their values to an actual boolean value.
Posted by Dan G. Switzer, II on Oct 18, 2006 at 2:38 PM
@Ben:
I just ran that code under CFMX 7,0,2,142559 and here's what my log looks like after several runs:
OnApplicationStart
OnSessionStart
OnRequestStart
OnRequest
OnRequestEnd
OnSessionEnd : [ID - 2100] [TOKEN - 11429582]
OnSessionStart
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnSessionEnd : [ID - 2100] [TOKEN - 11429582]
OnApplicationEnd : [NAME - App Event Testing 2]
OnApplicationStart
OnSessionStart
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
OnRequestStart
OnRequest
OnRequestEnd
(I just rapidly hit refresh on my browser.)
Posted by Dan G. Switzer, II on Oct 18, 2006 at 2:42 PM
Dan,
I tried taking out the CFReturn statements at one point and it didn't seem to matter. The test you just ran, did you leave those in?
Maybe it's just my machine then :(
Posted by Ben Nadel on Oct 18, 2006 at 2:50 PM
@Ben:
I ran the code as-is. A couple of notes:
1) Try copying and pasting the code from this blog--to make sure there aren't any funky characters in your template (I've seen templates behave strangely when saved in one charset that actually contained invalid chars.)
2) Check the version of your server. Perhaps you're missing a patch (or I am) and it's something w/the version of CFMX you're running. I'm using teh DevNet edition.
Posted by Dan G. Switzer, II on Oct 18, 2006 at 3:08 PM
Just so you don't think it is just you, I was getting the exact same error several months ago with similar code. Never found a solution.
Here is the code I used:
<cffunction name="onApplicationEnd" returnType="void" output="false">
<cfargument name="applicationScope" required="true">
</cffunction>
<cffunction name="onSessionEnd" returnType="void" output="false">
<cfargument name="sessionScope" type="struct" required="true">
<cfargument name="appScope" type="struct" required="false">
</cffunction>
It didn't happen on my dev machine, it was only on the live site.
I still had one of the error dump emails:
TagContext array [empty]
Type java.lang.NullPointerException
Type: Expression Template: C:\dev\ozarka\Application.cfc? Tag Context:
array [empty]
Exception:
struct
Detail An exception occurred when invoking a event handler method from Application.cfc The method name is: onSessionEnd.
Posted by Scott Pinkston on Oct 18, 2006 at 5:09 PM
Scott, thank you for making me feel that perhaps I wasn't a raving lunatic :)
Dan,
Yeah, copy and paste still the same issue. I am running Enterprise version 7,0,1,116466. Looks like we are missing the 7,0,2 patch. Hmmm, that might be it.
Posted by Ben Nadel on Oct 19, 2006 at 7:24 AM
I started getting this error after doing a structclear on the session and application scope. I removed the function, onRequestStart and am now getting the error in a different template all together.
Did you ever figure out a direct cause for this error?
Posted by Johnny on Aug 28, 2008 at 11:08 PM