“java.io.IOException: No locks available” error when using mvn

Tried to use mvn for compiling a Java library but got error:

[WARNING] Failed to read tracking file /adminhome/yandong/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/2.6/_remote.repositories
java.io.IOException: No locks available
at sun.nio.ch.FileDispatcherImpl.lock0(Native Method)
at sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:90)
at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1021)

 

turned out it’s about NFS lock service since the directory is mounted through network. The Linux distribution at work is customized and there’s no way to install the service as some Google search suggested. Solution: point mvn’s repository directory to some local space and the problem is gone. To be specific, in file apache-maven-${version}/conf/settings.xml: uncomment and update line:

<localRepository>some_local_directory</localRepository>

and re-run mvn.

Leave a comment