Note that there are some explanatory texts on larger screens.

plurals
  1. POonApplicationEnd - Is CF actually shutting down?
    text
    copied!<p>I need to use <code>onApplicationEnd()</code> as part of <code>Application.cfc</code> to execute a call on a 3rd party Java object to close a connection to another device on the network. </p> <p>The code I have worked perfectly if I call it as a normal request, but when I place it in the <code>onApplicationEnd()</code> method I'm running into some errors. These errors suggest that CF might in fact be shutting down already to the point where I cannot access these 3rd party Java classes. </p> <p>Code:</p> <pre><code> &lt;cffunction name="onApplicationEnd" returnType="void"&gt; &lt;cfargument name="appScope" required="true" /&gt; &lt;cfset var logLocation = "test" /&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - **** START RUN ****" /&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() called " /&gt; &lt;cftry&gt; &lt;cfif structKeyExists(ARGUMENTS, "appScope")&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - ARGUMENTS.appScope is defined" /&gt; &lt;cfelse&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - ARGUMENTS.appScope is undefined! " /&gt; &lt;/cfif&gt; &lt;!--- Check if we have a test crypto object in scope, and if so close it's connection ---&gt; &lt;cfif structKeyExists(ARGUMENTS.appScope, "testCrypto")&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - crypto object exists in app scope" /&gt; &lt;cfset ARGUMENTS.appScope.testCrypto.closeConnection() /&gt; &lt;&lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - closed crypto server connection" /&gt; &lt;cfelse&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - NO crypto server connection present to close" /&gt; &lt;/cfif&gt; &lt;cfcatch type="any"&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() - Error - #cfcatch.message#" /&gt; &lt;/cfcatch&gt; &lt;/cftry&gt; &lt;cflog file="#logLocation#" text="*** [Application.cfc] - #timeformat(now(),'HH:mm:ss' )# - onApplicationEnd() ended " /&gt; &lt;/cffunction&gt; </code></pre> <p>The line to close the connection on my object is failing with the message: 'java.lang.IllegalStateException: Shutdown in progress'.</p> <p>Here are the full logs for one run:</p> <pre><code>"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 " </code></pre> <p>Is there restrictions to what I can do in <code>onApplicationEnd()</code> and if so is there any work around? </p> <p>I am using CF 8 (8,0,1,195765) Developer Edition on a Windows XP machine. </p> <p>Also, if I run CF in a console window and press CTRL-C I see this, but I also see this behaviour if I run <code>cfstop</code>. </p> <p>Many thanks in advance!</p> <p>EDIT: Some others had this issues <a href="http://www.opensubscriber.com/message/cf-talk@houseoffusion.com/4716595.html" rel="nofollow noreferrer">here</a>, but no solutions. </p> <p>EDIT: Removed thread example as it might be fogging the issue. Posted code and logs. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload