I found a problem when I recently installed JasperSoft’s reporting server. Everything was fine, except it would randomly slow down and start-up took a while. Looking in the logs, I kept getting this error.
Aug 20, 2013 11:59:43 PM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode WARNING: Could not lock User prefs. Unix error code 2. Aug 20, 2013 11:59:43 PM java.util.prefs.FileSystemPreferences syncWorld WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
I could not figure out why the server was slow and why I was getting these messages, and I had never really ran anything seriously on Tomcat so I didn’t have the mental framework to know where to look. Stumbling around, I found JMX extensions (blog post on that), and discovered that this method was pretty much holding up the whole thing:
A lightbulb turned on, and I realized that the JasperServer was trying to create a file in the Tomcat home directory which was owned by root, not Tomcat. So, I simply changed the owner and it started to work. On Linux, specifically Ubuntu 12.04, I ran this command:
chown tomcat7:tomcat7 -R /usr/share/tomcat7
Suddenly, the problem went away.