12

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!

GavinWoods
  • 803
  • 2
  • 13
  • 28
  • Are they in your application scope? Also do you have "Save class files" checked under Server Settings > Caching? – kevink Feb 11 '10 at 22:07
  • Are you saving them to any persistent scope? Session/server/etc.? – Ben Doom Feb 11 '10 at 22:34
  • Check Admin > Data & Services > Web Services and see if the cfcs are registering themselves as web services, if so delete them from that screen and see if that helps. – kevink Feb 12 '10 at 01:41
  • None of them are registered as web services. I am however saving some of my CFCs to application and session scopes. What can I do to get around this? – GavinWoods Feb 12 '10 at 14:50
  • @Gavin Are you working on run-of-the-mill CFCs or web service CFCs? – Eric Kolb Feb 12 '10 at 16:25
  • I'm not running web service CFCs, so its a run-of-the-mill CFC. – GavinWoods Feb 12 '10 at 17:16
  • I can't test this now but try making a small cfm with one line And see if that reloads them, if it does I will move this to an answer – kevink Feb 13 '10 at 13:51
  • This should be helpful: http://stackoverflow.com/questions/3119119/restart-application-without-restarting-server – ale Nov 29 '11 at 20:25

8 Answers8

10

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
  • 12,814
  • 4
  • 34
  • 48
  • 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 Apr 16 '10 at 15:39
1

Uncheck "Component cache" in CFAdmin --> Caching

Also check CFAdmin --> Mappings and make sure the CFC folder is pointing to the right one if any. Sometimes people clone their source code and don't change the mapping to the new folder.

chung lee
  • 11
  • 2
1

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
  • 7,647
  • 14
  • 53
  • 87
0

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

Caching > Trusted Cache

Caching > Save class files

Dan Sorensen
  • 10,465
  • 18
  • 65
  • 98
0

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

Phillip Senn
  • 43,069
  • 83
  • 242
  • 359
0

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
  • 4,756
  • 7
  • 33
  • 46
  • 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. – GavinWoods Feb 17 '10 at 21:37
0

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>
0

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
  • 41
  • 2