Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with:

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

By Ben Nadel on
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

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

Reply to this Comment

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.

Reply to this Comment

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?

Reply to this Comment

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.

Reply to this Comment

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

Reply to this Comment

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?

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
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.