I need to use onApplicationEnd()as part of Application.cfcmaking a call to a third-party Java object in order to close the connection to another device on the network.
The code that I worked fine if I call it a regular request, but when I put it in a method onApplicationEnd(), I encounter some errors. These errors indicate that CF can actually be completed to such an extent that I cannot access these third-party Java classes.
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 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 to my object fails with the message: "java.lang.IllegalStateException: shutting down."
Here are the complete 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 "
Are there any restrictions on what I can do in onApplicationEnd(), and if so, is there any work?
CF 8 (8,0,1,195765) Developer Edition Windows XP.
, CF CTRL-C, , , cfstop.
!
: , .
EDIT: , . .