Skip to main content
Ben Nadel at CF Summit West 2024 (Las Vegas) with: Brian Chouteau
Ben Nadel at CF Summit West 2024 (Las Vegas) with: Brian Chouteau

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

By
Published in Comments (8)

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!

Want to use code from this post? Check out the license.

Reader Comments

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

15,848 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.

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

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.

15,848 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??

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

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel