Error trying to delete file in use (registering services) on Windows

108 views
Skip to first unread message

Wellington Souza

unread,
Mar 28, 2017, 2:44:31 PM3/28/17
to CAS Community
I have tested the project cas-overlay-demo on Mac/Linux and it works very well, but to my surprise on Windows I got some errors, trying to delete files. This post is a transcription of one issue that was opened to cas-overlay-demo because @mmoayyed gave me good reasons to do that.

First of all, I have cleaned manually, restart the windows and the problem still persist. 
@leleuj gave me a glue with the classname AbstractResourceBasedServiceRegistryDao and then I did a little bit more investigation, made some changes to see what was happening.

What I found was that the file descriptors was being opening (scheduled tasks) and another task trying to delete the file. Differently of *nix systems, the Windows lock a file when it is opened (even just for read). It seems there is one or more scheduled tasks reloading the directory "${java.io.tmpdir}/cas/services". I believe is a good idea to use a explicit lock file (opened for loading) in the temp directory and if the lock file exists do not try to delete because it's being used.

To verify that it was happening, first I executed the server and management using different temp directory

 java -jar -Djava.io.tmpdir=c:\temp\cas cas-overlay-server-demo\target\cas.war
 java -jar -Djava.io.tmpdir=c:\temp\mgr cas-overlay-management-demo\target\cas-management.war

And the errors was became less frequent (loading almost always with success the cas server).

To prove that has an process scheduled I made a couple changes: Created new classes under cas-overlay-server-demo using System.out.println to show when the file is being loaded.

I believe the version 5.0.4 is still not fully tested on Windows systems. I don't know how CAS works internally, but the approach to register/delete can't be done on this way on Windows Systems. Maybe creating a explicit lock file when the file is being loaded then the delete task should wait until the lock file is not in there anymore.





cas-server-logs.zip
cas-overlay-server-demo.zip

Misagh Moayyed

unread,
Mar 28, 2017, 5:27:49 PM3/28/17
to cas-...@apereo.org

First of all, I have cleaned manually, restart the windows and the problem still persist. 
@leleuj gave me a glue with the classname AbstractResourceBasedServiceRegistryDao and then I did a little bit more investigation, made some changes to see what was happening.

Great analysis. That file/component is where you need be to poke at this a bit more. I suggest you start by setting up a development environment, cloning the repo and stepping through the code to figure out the locking issue on windows. 
Reply all
Reply to author
Forward
0 new messages