File lock issue with reading jar files from gradle user cache

Could not resolve group:com.test.plm.spm, module:spm-core, version:latest.milestone.

Required by:

com.test.plm.spm.bam.ae:spm-bam-ae-impl:8.2.5-m31-SNAPSHOT

java.io.FileNotFoundException: C:\Users\krik.gradle\caches\artifacts-8\artifacts-8.lock (The process cannot access the file because it is being used by another process) > Could not resolve group:com.test.plm.spm, module:spm-util, version:latest.milestone.

Required by:

com.test.plm.spm.bam.ae:spm-bam-ae-impl:8.2.5-m31-SNAPSHOT

java.io.FileNotFoundException: C:\Users\krik.gradle\caches\artifacts-8\artifacts-8.lock (The process cannot access the file because it is being used by another process)

Hi,

Can you please provide the full stacktrace for this error. To do this, you need to run Gradle with the ‘-s’ switch.

Caused by: org.gradle.internal.UncheckedException: java.io.FileNotFoundException: C:\Users\lkeyoth.gradle\caches\artifacts-8\artifacts-8.lock (The process cannot access the file because it is being used by another process)

at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:39)

at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:71)

at org.gradle.cache.internal.DefaultCacheAccess.getLock(DefaultCacheAccess.java:274)

at org.gradle.cache.internal.DefaultCacheAccess.access$100(DefaultCacheAccess.java:39)

at org.gradle.cache.internal.DefaultCacheAccess$UnitOfWorkFileAccess.writeToFile(DefaultCacheAccess.java:285)

at org.gradle.cache.internal.MultiProcessSafePersistentIndexedCache.getCache(MultiProcessSafePersistentIndexedCache.java:84)

at org.gradle.cache.internal.MultiProcessSafePersistentIndexedCache.get(MultiProcessSafePersistentIndexedCache.java:35)

at org.gradle.api.internal.artifacts.ivyservice.dynamicversions.SingleFileBackedModuleResolutionCache.getCachedModuleResolution(SingleFileBackedModuleResolutionCache.java:66)

at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.maybeUseCachedDynamicVersion(CachingModuleVersionRepository.java:93)

at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.findModule(CachingModuleVersionRepository.java:83)

at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.getDependency(CachingModuleVersionRepository.java:79)

at sun.reflect.GeneratedMethodAccessor98.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyContextualiser$1.invoke(IvyContextualiser.java:44)

at $Proxy33.getDependency(Unknown Source)

at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.findLatestModule(UserResolverChain.java:71)

at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.resolve(UserResolverChain.java:52)

… 99 more

Caused by: java.io.FileNotFoundException: C:\Users\lkeyoth.gradle\caches\artifacts-8\artifacts-8.lock (The process cannot access the file because it is being used by another process)

at java.io.RandomAccessFile.open(Native Method)

at java.io.RandomAccessFile.(RandomAccessFile.java:216)

at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.(DefaultFileLockManager.java:96)

at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:68)

… 115 more

Is this happening consistently?

How often does it happen?

If its intermittent, is there any triggering factor that you’ve noticed?

Can you please post your Gradle version and information about your OS version.

i saw this happen in multiple machines. very random but is happening at lease once a day. I have to restart my machine as a work around. i got his error again now.

I’ve raised GRADLE-2315.

It would be worth trying a later version of Gradle as a lot of work has gone on in this area in recent releases.

I have also seen gradle trip over its lockfile in multiple versions, including 1.0-rc-3 (seemed worst around milestone-5). It occurs only sporadically and seems to be linked to downloading a lot of artifacts, though I cannot reliably reproduce.

Could this note from the user guide be related? “The lock is held whenever the binary meta-data store is being read or written, but is released for slow operations such as downloading remote artifacts.”

Update after moving to gradle-1.0: still seeing this behavior sporadically, even when using --offline. I haven’t noticed any apparently trigger.