PLEASE HELP! Why Is This Application.cfc Throwing Errors?

Posted October 18, 2006 at 8:16 AM by Ben Nadel

Tags: ColdFusion

Can anyone help me out on this error? I thought that I had solved the problem in my other post, but it turns out, that was not causing the ColdFusion event error. The error popped back up again. Here is error:

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

What is going on? Here is Application.cfc Code:

  • <cfcomponent
  • displayname="Application"
  • output="true"
  • hint="Handle the application.">
  •  
  •  
  • <cfscript>
  •  
  • THIS.Name = "App Event Testing";
  • THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 0, 20 );
  • THIS.SessionManagement = true;
  • THIS.SessionTimeout = CreateTimeSpan( 0, 0, 0, 15 );
  • THIS.LoginStorage = "SESSION";
  • THIS.SetClientCookies = true;
  •  
  • </cfscript>
  •  
  •  
  • <cfsetting
  • requesttimeout="10"
  • showdebugoutput="false"
  • enablecfoutputonly="false"
  • />
  •  
  •  
  • <cffunction name="OnApplicationStart" access="public" returntype="boolean" output="true"
  • hint="Fires when the application is first created.">
  •  
  • <!--- Return out. --->
  • <cfreturn true />
  • </cffunction>
  •  
  •  
  • <cffunction name="OnSessionStart" access="public" returntype="void" output="true"
  • hint="Fires when the session is first created.">
  • </cffunction>
  •  
  •  
  • <cffunction name="OnRequestStart" access="public" returntype="boolean" output="true"
  • hint="Fires when prior to page processing.">
  •  
  • <!--- Define arguments. --->
  • <cfargument name="TargetPage" type="string" required="yes" />
  •  
  • <!--- Return out. --->
  • <cfreturn true />
  • </cffunction>
  •  
  •  
  • <cffunction name="OnRequest" access="public" returntype="void" output="true"
  • hint="Fires after pre page processing is complete.">
  •  
  • <!--- Define arguments. --->
  • <cfargument name="TargetPage" type="string" required="yes" />
  •  
  • <!--- Include the requested page. --->
  • <cfinclude template="#ARGUMENTS.TargetPage#" />
  • </cffunction>
  •  
  •  
  • <cffunction name="OnRequestEnd" access="public" returntype="void" output="true"
  • hint="Fires after the page processing is complete.">
  • </cffunction>
  •  
  •  
  • <cffunction name="OnSessionEnd" access="public" returntype="void" output="true"
  • hint="Fires when the session is terminated.">
  •  
  • <!--- Define arguments. --->
  • <cfargument name="SessionScope" type="struct" required="true" />
  • <cfargument name="ApplicationScope" type="struct" required="false" default="#StructNew()#" />
  • </cffunction>
  •  
  •  
  • <cffunction name="OnApplicationEnd" access="public" returntype="void" output="false"
  • hint="Fires when the application is terminated.">
  •  
  • <cfargument name="ApplicationScope" type="struct" required="false" default="#StructNew()#" />
  • </cffunction>
  •  
  •  
  • <cffunction name="OnError" access="public" returntype="void" output="true"
  • hint="Fires when an exception occures that is not caught by a try/catch.">
  •  
  • <!--- Define arguments. --->
  • <cfargument name="Exception" type="any" required="true" />
  • <cfargument name="EventName" type="string" required="false" default="" />
  •  
  • <cfsavecontent variable="strTemp">
  • <cfdump var="#ARGUMENTS.Exception#" />
  • </cfsavecontent>
  •  
  • <cffile
  • action="WRITE"
  • file="#ExpandPath( './error.htm' )#"
  • output="#strTemp#"
  • />
  • </cffunction>
  •  
  • </cfcomponent>

I have ONE other page in the system. The index.cfm page:

  • <cfoutput>
  •  
  • <cfdump var="#APPLICATION#" />
  •  
  • </cfoutput>

I cannot for the life of me figure this out. PLEASE HELP!



Reader Comments

Oct 18, 2006 at 9:11 AM // reply »
5 Comments

Wow, not sure what the problem is. I just copied your code into a temp directory on my server and it ran fine. Have you restarted your CF lately?

FWIW, I'm on Apache 2.0.58 (on XP) w/ Enterprise CF 7,0,2,142559


Oct 18, 2006 at 9:14 AM // reply »
10,640 Comments

6Dust,

Just to be clear, it's not writing any HTML file (error.htm) to the temp directory. You wouldn't be able to see the error on screen when running the index.cfm file.


Oct 18, 2006 at 10:02 AM // reply »
20 Comments

Ben,

Even I pasted your code in my system and run it, it works fine with no error. So where should I see the error?.

The file is not created and no dumping is there, is that your case?


Ed
Oct 18, 2006 at 10:05 AM // reply »
12 Comments

i confirm that. i did try to run it on my end and it worked just fine. and no html file with error was created. the html eror file is created only if i ty with a purpose to create errors in index.cfm.


Oct 18, 2006 at 10:53 AM // reply »
10,640 Comments

I tried stripping out the OnError method and obviously the page works fine (as the OnSEssionEnd and OnApplicationEnd are not browser-related issues). However, I am also seeing that NONE of the errors are getting logged in the ColdFusion Application.log file. How strange is that??


Oct 18, 2006 at 11:32 AM // reply »
20 Comments

Works fine for me too - CF MX 7 on Windows 2003 server...

Everyone here has run it successfully; have you tried deleting your files and recreating them from what you've posted on the blog?


Oct 18, 2006 at 12:26 PM // reply »
10,640 Comments

Seb et al,

I have tried moving files around to no avail... here is an update:

http://bennadel.com/index.cfm?dax=blog:355.view


rob
Dec 12, 2006 at 7:44 PM // reply »
1 Comments

heeyyyyyyyyyyyyyyyyyyyyy!!! sweet,,, this just made my day


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 12, 2012 at 3:37 AM
Learning ColdFusion 8: CFImage Part III - Watermarks And Transparency
Hi Ben, Just to ask currently it is placed bottom right corner, if i need to replace the same rendered image on the bottom left side or in the bottom center, how that can be calculated. bottom ce ... read »
Feb 11, 2012 at 9:29 PM
Use jQuery's SlideDown() With Fixed-Width Elements To Prevent Jumping
I can't say how glad I am that I found your post. Thank you very much. ... read »
Feb 10, 2012 at 7:21 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
Update! Instead of $(eval(options.insertAfter)).after(data['insertData']); I now use: var ajaxNode = document.createElement('span'); var parent = $(eval(options.insertAfter))[0].parentNode; ... read »
Feb 10, 2012 at 6:18 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
encountered this same, what I consider, jQuery bug last week. I'm building a site in which I load some content via AJAX. This content contains Linkedin share button placeholders which Linkedin API ne ... read »
Feb 10, 2012 at 11:30 AM
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
After you understand the concepts here, this is an awesome cheatsheet for enabling CORS in just about anything http://enable-cors.org/ ... read »
JM
Feb 10, 2012 at 9:10 AM
My Safari Browser SQLite Database Hello World Example
@Amy, Here is a very good tutorial on how to use JOIN: http://www.sqltutorial.org/sqljoin-innerjoin.aspx ... read »
Feb 10, 2012 at 4:42 AM
Building A Twitter-Inspired RESTful API Architecture In ColdFusion
This is great, very useful Ben. I spotted a small typo in the api.cgm listing: <cfthrow type="Unauthroized" /> Cheers Stefan ... read »
Feb 9, 2012 at 10:35 PM
CFDirectory Filtering Uses Pipe Character For Multiple Filters (Thanks Steve Withington)
I was wondering if there would be a filter you could apply so that you got everything but what you included in the filter. As in show me all docs that are not a .pdf. ... read »