Thanks for the replies so far. Here is the code:
<cffunction name="onApplicationEnd" returnType="void">
<cfargument name="appScope" required="true" />
<cfset var logLocation = "test" />
<cflog file="#logLocation#" text="*** [Application.cfc] - **** START RUN ****" />
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() called " />
<cftry>
<cfif structKeyExists(ARGUMENTS, "appScope")>
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - ARGUMENTS.appScope is defined" />
<cfelse>
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - ARGUMENTS.appScope is undefined! " />
</cfif>
<!--- Check if we have a test crypto object in scope, and if so close it's connection --->
<cfif structKeyExists(ARGUMENTS.appScope, "testCrypto")>
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - crypto object exists in app scope" />
<cfset ARGUMENTS.appScope.testCrypto.closeConnection() />
<<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - closed crypto server connection" />
<cfelse>
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - NO crypto server connection present to close" />
</cfif>
<cfcatch type="any">
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - Error - #cfcatch.message#" />
</cfcatch>
</cftry>
<cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() ended " />
</cffunction>
The line to close the connection on my object is failing with the message: 'java.lang.IllegalStateException: Shutdown in progress'.
Here are the full logs for one run:
"Information","Thread-8","10/23/09","09:05:54",,"*** [Application.cfc] - **** START RUN
"Information","Thread-8","10/23/09","09:05:54",,"*** [Application.cfc] - 09:05:54 - onApplicationEnd() called "
"Information","Thread-8","10/23/09","09:05:54",,"*** [Application.cfc] - 09:05:54 - ARGUMENTS.appScope is defined"
"Information","Thread-8","10/23/09","09:05:54",,"*** [Application.cfc] - 09:05:54 - onApplicationEnd() - crypto object exists in app scope"
"Information","Thread-8","10/23/09","09:05:54",,"*** [Application.cfc] - 09:05:54 - onApplicationEnd() - Error - Shutdown in progress"
"Information","Thread-8","10/23/09","09:05:55",,"*** [Application.cfc] - 09:05:55 - onApplicationEnd() ended "
I really hope there is a work-around. The same issue occurs when I run CF as a console window and stop it with CTRL-C or if I run cfstop.
Cheers,
Ciaran