解決 java.util.prefs.BackingStoreException 報錯問題
阿新 • • 發佈:2018-12-07
伺服器日誌顯示,半分鐘報一次錯誤:
Mar 29, 2016 10:37:23 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode WARNING: Could not lock User prefs. Unix error code 2. Mar 29, 2016 10:37:23 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode WARNING: Could not lock User prefs. Unix error code 2. Mar 29, 2016 10:37:23 AM java.util.prefs.FileSystemPreferences syncWorld WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock. Mar 29, 2016 10:37:23 AM java.util.prefs.FileSystemPreferences syncWorld WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock. Mar 29, 2016 10:37:25 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode WARNING: Could not lock System prefs. Unix error code 0. Mar 29, 2016 10:37:25 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode WARNING: Could not lock System prefs. Unix error code 0. Mar 29, 2016 10:37:25 AM java.util.prefs.FileSystemPreferences syncWorld WARNING: Couldn't flush system prefs: java.util.prefs.BackingStoreException: Couldn't get file lock. Mar 29, 2016 10:37:25 AM java.util.prefs.FileSystemPreferences syncWorld WARNING: Couldn't flush system prefs: java.util.prefs.BackingStoreException: Couldn't get file lock. 本來無傷大雅,但是把日誌都給我頂沒了讓我很惆悵,於是決定解決掉他,多方查詢,發現造成這個問題的原因是jdk去鎖定使用者配置的時候無法鎖定,其實就是各種許可權問題,好多文章說去掉/etc/.java就可以了 我試了試 不行 看了如下兩篇文章 http://www.ithao123.cn/content-10680341.html http://www-01.ibm.com/support/docview.wss?uid=swg21515420 得到了一些啟發 然後我發現需要給tomcat的登入使用者賦值/etc/.java的操作許可權,由於是自帶的tomcat6,我開啟tomcat6.conf檔案後發現這麼一行: TOMCAT_USER="tomcat" 出於偷懶,果斷改成root,至此,問題解決 下面才是重點但是畢竟讓tomcat拿到root許可權不是什麼安全的事情,如果日後集團安全檢查,一定會掃出漏洞,所以把tomcat使用者的許可權都賦值: # chown tomcat:tomcat -R /etc/.java/.systemPrefs # chown tomcat:tomcat -R /etc/.java # chown tomcat:tomcat -R /var/lock/subsys/tomcat6 # chown tomcat:tomcat -R /var/log/tomcat6