views:

635

answers:

8

Hello,

I develop coldFusion applications on my laptop with it's own ColdFusion 8 server with IIS which run on Windows Vista. I am having a rather annoying problem.

The problem is whenever I make any changes to my CFC's, it appears that unless I restart my ColdFusion Application server, the changes to my CFC's will not take effect unti I do so. Often times, I have to restart my whole machine because Windows can't restart the ColdFusion Application Server service. Is there a better way to reset the ColdFusion Server's cfc cache?

This is beginning to suck up a lot of time just having to restart every so often after I make a change. Any insight would be greatly appreciated!

Thank you!

+1  A: 

im not sure if this is in other versions of CF also but in CF9 you can do ApplicationStop() and it will reset the CFApplication and reload it.

Faisal Abid
That's exactly what I need! But I'm running CF8. Its not supported in that version :(
Gavin
A: 

In your Coldfusion Administrator, do you have either of the following enabled (checked)?

Caching > Trusted Cache

Caching > Save class files

Dan Sorensen
None of them are enabled.
Gavin
A: 

Just asking the obvious: Are you calling these functions from onApplicationStart?

cf_PhillipSenn
No, the functions are not called onApplicationStart.
Gavin
A: 

Maybe try the "Clear template cache" button under CF Admin > Caching.

This has happened to me before. I usually have to click the button several times for CF register the changed files.

Might also try unchecking everything under Caching as well. Note: Only do this for development machines!!!

Eddie
Thank you for the response. I tried it but didnt work. This has only typically worked for my .cfm files in the past anyway. I tried enabling then disabling the cache options as well, no joy :(. It almost sounds like its going to have to be a constant annoyance of restarting CF application server until my company decides to upgrade to CF9 or later.
Gavin
+2  A: 

I guarantee you are creating these as objects in some sort of persistent scope, eg: application, session scopes. What I generally do to avoid this problem during development is create a url parameter and check for that in the application.cfm/cfc file (or wherever you are creating the objects) and recreate the objects if that url parameter is detected.

Example:

<cfif NOT structKeyExists(application,"myObj") OR structKeyExists(url,"reinit")>
    <cfset application.myObj = createObject("component","path.to.cfc") />
</cfif>

of course you would need to do this with every object that you are having a problem with.

Ryan Guill
this has been giving me headaches for so long. i didn't realize that putting something in application scope actually saves the code. i thought it would just save the object's metadata. thanks!
Kip
A: 

If you must have caching in dev, you might do what I do:

First put a check for a URL flag to the top of your onRequest() method which will call the onApplicationStart() method:

<cfif IsDefined("URL.dev")>
    <cflock timeout="5" scope="Session" type="Exclusive">
        <cfif URL.dev EQ true>
            <cfset SESSION.debug = true />
        <cfelse>
            <cfset StructDelete(SESSION, "debug") />
        </cfif> 
    </cflock>
</cfif>

<cflock timeout="5" scope="Session" type="Readonly">
    <cfif IsDefined("URL.appreset") or IsDefined("SESSION.dev")>
            <cfset StructClear(SESSION) />
            <cfset onApplicationStart() />
        </cfif>
</cflock>   

This will fix most of your problems. However, if you have a problem in a class that you are loading, it won't get far enough to check for this flag. The solution I use for this:

Add the following to the bottome of your onError() method:

<cfif IsDefined("APPLICATION")>
      <cfset StructClear(APPLICATION) />
</cfif>

Finally, you want to check that the APPLICATION object exists and that each class you are declaring as part of the APPLICATION scope exists or you want to recall onApplicationStart(). To do this, add the following right below the first block of code at the top of onRequestStart():

<cfif not IsDefined("APPLICATION")
    OR not StructKeyExists(APPLICATION, "[ClassName1]")
    OR not StructKeyExists(APPLICATION, "[ClassName2]")
    ...>
    <cfset onApplicationStart() />
</cfif>
Shelby Spencer
A: 

I had the exact same problem, sometimes I had to restart the machine if the changes would not reflect after starting the server the service manager.

What I do is, in (Administrator,Caching): 1. I unchecked all cache options 2. I set the text box values to "0" 3. I Keep the (Administrator,Caching) page open when developing, so that when I upload a change and it doesn't reflect, I just hit the "Clear Template Cache Now".

This is what is working for me on CF8, Built In Web Server, XP.

Nich
A: 

I am having the same problem as the original post. However, running onApplicationStart() to reinitialise the cfc has no effect, and clearing the template cache in cfadmin has no effect.

RENAMING the cfc (and adjusting my code accordingly) DOES have an effect, but when reverting the cfc back to its original name and calling a new createObject() on it, the OLD version of the cfc gets recreated.

It appears to me that CF8 is storing a copy of the old cfc somewhere in its memory which it uses whenever createObject() is called on it, regardless of any changes made to the code in the cfc.

Anybody got any ideas how to purge this cfc from CF8's memory?

Junglefish