2013-07-16 36 views
3

建設火花項目,我試圖使用sbt。下列異常發生:「沒有鎖可用」當運行sbt cmd

java.io.IOException: No locks available 
    at sun.nio.ch.FileChannelImpl.lock0(Native Method) 
    at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:871) 
    at java.nio.channels.FileChannel.tryLock(FileChannel.java:962) 
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:88) 
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81) 
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102) 
    at xsbt.boot.Using$.withResource(Using.scala:11) 
    at xsbt.boot.Using$.apply(Using.scala:10) 
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62) 
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52) 
    at xsbt.boot.Locks$.apply0(Locks.scala:31) 
    at xsbt.boot.Locks$.apply(Locks.scala:28) 
    at xsbt.boot.Update.apply(Update.scala:100) 
    at xsbt.boot.Launch.update(Launch.scala:279) 
    at xsbt.boot.Launch.xsbt$boot$Launch$$retrieve$1(Launch.scala:149) 
    at xsbt.boot.Launch$$anonfun$3.apply(Launch.scala:157) 
    at scala.Option.getOrElse(Option.scala:120) 
    at xsbt.boot.Launch.xsbt$boot$Launch$$getAppProvider0(Launch.scala:157) 
    at xsbt.boot.Launch$$anon$2.call(Launch.scala:142) 
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:98) 
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81) 
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102) 
    at xsbt.boot.Using$.withResource(Using.scala:11) 
    at xsbt.boot.Using$.apply(Using.scala:10) 
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62) 
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52) 
    at xsbt.boot.Locks$.apply0(Locks.scala:31) 
    at xsbt.boot.Locks$.apply(Locks.scala:28) 
    at xsbt.boot.Launch.locked(Launch.scala:178) 
    at xsbt.boot.Launch.app(Launch.scala:93) 
    at xsbt.boot.Launch.app(Launch.scala:91) 
    at xsbt.boot.Launch$.run(Launch.scala:51) 
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45) 
    at xsbt.boot.Launch$.launch(Launch.scala:65) 
    at xsbt.boot.Launch$.apply(Launch.scala:16) 
    at xsbt.boot.Boot$.runImpl(Boot.scala:31) 
    at xsbt.boot.Boot$.main(Boot.scala:20) 
    at xsbt.boot.Boot.main(Boot.scala) 
Error during sbt execution: java.io.IOException: No locks available 

的SBT版本我曾嘗試:0.11.3-2和0.13.0 我ASLO試圖改變SBT啓動目錄,以避免權限問題。

任何想法,我做錯了。

回答

0

我真的不知道什麼是錯,但我懷疑你的問題可能類似於this one。你正在用你的項目和/或你的sbt和/或你的主目錄拷貝到NFS掛載上嗎?你有沒有嘗試完全從本地磁盤構建?

2

SBT依賴於你的JVM的財產「的user.home」作爲工作目錄,並似乎獲取鎖在裏面,如果你的「的user.home」指向一個NFS目錄當中沒有安裝NFS鎖服務,然後你會得到「無鎖可用」的錯誤。

我多次遇到這個錯誤(另一種情況是maven嘗試獲取$ HOME/.m2 /下的某些鎖)。你有兩個選擇:

  • 安裝NFS鎖服務
  • 泰爾SBT不使用你的NFS目錄,通過性能-Duser.home = /路徑/中/本地/磁盤。例如。
    • sbt clean compile -Duser.home=/disk1/myhome
+0

是的,我們嘗試獲取〜/ .ivy2 /中的鎖,以確保只有一個進程正在觸摸常青藤緩存,以避免我們所遇到的腐敗問題。 你可以禁用它。 – jsuereth

+0

感謝您的通知。我認爲獲得鎖定以避免腐敗對我來說是必要的,而maven無論如何都會在$ HOME中獲得鎖定,所以我只使用本地$ HOME。不幸的是,我公司的集羣沒有NFS鎖... – zhaown

1

默認SBT試圖啓動或做相關性解析時,需要一個獨佔鎖。這是爲了避免高速緩存損壞,或刪除另一個進程正在使用的JAR文件(這可能會導致一些非常奇怪的錯誤)。

這種鎖定通常與分佈式文件系統不兼容。有時甚至在本地文件系統上出現意外的實現失敗。檢查你的FS,看看Java是否支持鎖定它。

你應該能夠通過禁用此鎖定:

sbt -Dsbt.boot.lock=false 

Addtionally,如果你有自己的sbt.boot.properties文件,你需要以下條件:

[boot] 
lock: false 

這將禁用內部鎖定功能該啓動程序依次禁用所有使用此功能的sbt項目的鎖定。 AFAIK這意味着sbt中的所有內容,儘管一些插件可能直接使用JDK鎖定API。