Skip to main content
Known Participant
October 11, 2018
Question

ColdFusion.exe locking files

  • October 11, 2018
  • 7 replies
  • 4963 views

Hi,

I have a current development environment where we use a program called GoodSync to copy files from our local computer to a development server where we can then test our code.  We don't run CF locally on our own desktop/laptops.  Usually this works just fine but occasionally we have an issue where we can't copy our files to the server because the file gets locked by ColdFusion.exe.

Any ideas why ColdFusion is locking files and not releasing them?  We have to restart the CF service in order to clear the locks.  It seems like this is happening by mistake for some reason.  I've never encountered it in any other environment.

-Steve

    This topic has been closed for replies.

    7 replies

    New Participant
    September 24, 2021

    I have had the same problem after running the CF2021 Code Analyzer.  Any files that show an error are locked, they can be edited but they cannot be deleted. If the error in the file is fixed and the Code Analyzer is re-run and the file no longer throws an error then the file can be deleted.  This suggests any file that throws a coldfusion error becomes locked by coldfusion.exe  if the error is fixed and run without any cf errors then it is released by coldfusion.exe.  I hope that helps someone!

    Charlie Arehart
    Braniac
    September 26, 2021

    Clive, just to be clear, do you mean the security code analyzer (run via cf builder) or the compatibility code analyzer (run from the cf admin)?

     

    Either way, this is very surprising to hear. I'd like to confirm it, when I get a chance. And are you on any update of CF2021 (currently 1 or 2)?

    /Charlie (troubleshooter, carehart. org)
    New Participant
    September 29, 2021

    Thank you for following up Charlie. (I started with CF back in 1998 so I recognise your name from way back then!)

    I am just migrating from cf2016 to cf2021 so ran the cfadmin2021 Code Analyzer (Debugging & Logging > Code Analyzer) Version of code to test: CF2016

    (New versino is: CF Version: 2021,0,02,328618)

    1. Error Found on a page because it had a requestTimeOut="900" under a CFSCHEDULE tag and requestTimeout is deprecated in cf2021.  

    2. It is possible to open the page and edit it but it is not possible to delete it because windows says that the file is being used by coldfusion.exe

    3. Edit the page by removing the requestTimeout attribute

    4. Re-run the Code Analyzer as before.... the page is no longer shown as having an error.

    5. The page can now be deleted by windows in the normal way.

    This suggests that when the analyzer has found a problem with the file it holds on to it sufficiently to stop windows from deleting it but does allow it to be edited!

     

    I hope that helps you figure out what is going on!

    February 8, 2019

    moving the folder _gsdata_ to a location outside the webroot, and changing GoodSync's settings accordingly;

    2) leaving _gsdata_ in the webroot, but denying ColdFusion access to the directory. You could do this as follows:

    a) right-cick on the folder _gsdata_ and select Properties;

     check click on the tab Security, then on the button Edit;

    c) click on Add, and add the user, Local Service (that is the user ColdFusion runs as by default);

    d) in the resulting user-interface, click in the checkboxes todeny Local Service all permissions;

    e) click on the Apply button.

    Although check Windows Resource Protection Could Not Perform The Requested Operation

    Known Participant
    February 7, 2019

    New information on this issue... it seems like coldfusion only locks the file after you've uploaded code to the server and it encounters an error processing the cfm file.

    For instance, I've been working on all day while GoodSync copies files to the server via an FTP account and everything has worked fine.  Then a minute ago, I forgot the closing parenthesis on a function call such as "myfunction(param1, param2" no closing parenthesis after param2.  Navigated to my file through a web browser, saw the detailed CF error message.  Went back and corrected my error and upon uploading to the server was told the destination file is locked by coldfusion.exe and can't be overwritten.

    -Steve

    WolfShade
    Braniac
    February 7, 2019

    Y'know, I wonder.  The other day I had an external USB drive plugged in, copying files.  When I tried to use the "Safely remove hardware and reject media" option before unplugging the drive, I get a message that Windows can't disconnect the drive because a program is still using it.  Which was odd because the files had finished being copied.  But when I closed Windows Explorer and tried again, it worked.

    So, I wonder if ColdFusion is throwing the error and not letting go of the file.  As opposed to actually locking the file.  Maybe, just maybe, and I know I'm clutching at straws, here.. maybe CF is still "using" the .cfm file and Windows won't let anything over-write a file that is being used.

    Just my two cents.

    V/r,

    ^ _ ^

    Charlie Arehart
    Braniac
    October 27, 2018

    I'll add that while you both seem to be presuming that is doing this lock "for no good reason", I would say I'm not aware of any reason that cf would lock random files or folders, even if they are simply in the web root, by default.

    I would wonder if some user-selected feature or process running in cf is behind this. Steve, would you contend that this is a stock cf (so no changed admin features that might be related to this)   and would you feel it's "doing nothing" to or with the files?

    If so, have you found any pattern to when the files become locked after the cf restart? Mins? Hours? Any action preceding that?

    /Charlie (troubleshooter, carehart. org)
    Known Participant
    October 27, 2018

    Yes, I would consider this a stock CF install.  Since these files are in the _gsdata_ folder, even though its under the webroot, I would think that CF would only need to lock these files if it was requested like you said by a user action or script of some sort, which I'm sure wouldn't be happening.

    I haven't noticed a pattern yet.  Sometimes it will go days working just fine and then once you get the locked file problem once, your likely going to get it over and over again.  When that happens I point my IDE at a mapped drive to that folder and work on them that way so that Goodsync doesn't have to do anything, but file access is slower since the server is in Azure.

    BKBK
    Braniac
    November 28, 2018

    It's definitely ColdFusion doing this.  It's a constant problem.  Basically causes development time to triple or quadrupal.  Each time Goodsync copies the file (or manually via ftp through FileZilla) CF locks the file, I can test it, but then to change my file again, I have to RDP to the server, run procexplorer, find the process, kill it and test again.  But of course, killing CF, means after I copy my file successfully, I now have to log in to my app again because my session is dead, find the screen I was on, which sometimes can be several clicks or setup to get my test back to the right spot and try again.  And repeat and repeat all day long.  Really frustrating.


    ColdFusion is not to blame. It is apparently using the file as intended. The component, IConXService.cfc, is locked because ColdFusion is running it.

    In any case, as I said earlier, it might still be possible to copy the locked files. Have you applied the GoodSync setting​, 'Shadow Copy'?

    Inspiring
    October 26, 2018

    What files are you talking about? Source files like .cfm or .cfc?

    When you use ColdFusion to read data from .xlsx files using POI a lock is maintained because some JAVA object was not closed correctly. ColdFusion also maintains a lock on .jar file imported using this.javaSettings in Application.cfc

    Known Participant
    October 26, 2018

    Yea, usually it's the temporary files that goodsync creates, but it creates them in the sandbox webroot in a folder called _gsdata_ so CF still sees them.  There is no denying that coldfusion.exe opens them for some reason because I can clearly see that in Windows and Process Explorer.  I can kill the locks labeled coldfusion.exe or bounce the service and it's instantly fixed.  But to do this everytime I change a file during development is not productive.  Most days it works perfectly fine, but then we'll get a day where for several hours in a row there is nothing you can do but kill processes on every file change.  Maybe Goodsync can store that _gsdata_ folder outside the webroot.

    BKBK
    Braniac
    October 27, 2018

    AdeptDeveloper​, thanks for your explanation. You've made it clear what the problem is. ColdFusion is apparently sticking its nose where it don't belong.

    I can think of two possible solutions:

    1) moving the folder _gsdata_ to a location outside the webroot, and changing GoodSync's settings accordingly;

    2) leaving _gsdata_ in the webroot, but denying ColdFusion access to the directory. You could do this as follows:

        a) right-cick on the folder _gsdata_ and select Properties;

        b) click on the tab Security, then on the button Edit;

        c) click on Add, and add the user, Local Service (that is the user ColdFusion runs as by default);

        d) in the resulting user-interface, click in the checkboxes to deny Local Service all permissions;

        e) click on the Apply button.

    N.B: The second solution will only work if GoodSync isn't running as Local Service. If it is, then a variation of this solution is to change the account under which ColdFusion is running. For information on this, Google, for example "running coldfusion as a user" or "running coldfusion under a domain account". After you create the new account, follow the steps in 2), and deny access to the new account.

    BKBK
    Braniac
    October 13, 2018

    This is perhaps a GoodSync problem. Goodsync might be unable to copy to a file location if the file is currently being processed by ColdFusion.

    In any case, GoodSync should be able to copy a locked file. Check out the GoodSync documentation.

    Known Participant
    October 25, 2018

    I don't think so because the docs say that it can't copy TO (or over) a locked file.  And if I go into Process Explorer and investigate what locks are on that file, it's coldfusion.exe.  I can't delete the file from the server through Windows Explorer either.  Or overwrite it via FTP.  I have to bounce the CF Service in order to free the file up again.

    WolfShade
    Braniac
    October 11, 2018

    Are there log entries (either the physical server or webserver or CFAdmin) indicating that ColdFusion.exe is locking the files?

    I'm just curious as to how you came to the conclusion that CF.exe is the culprit.

    V/r,

    ^ _ ^

    Known Participant
    October 11, 2018

    No and ColdFusion runs the files properly if I run it in a web browser.

    I determined it was ColdFusion.exe using Process Explorer.