Different users under Linux are preferred for Java system
I try to run multiple JVMs (including Tomcat) of different users on a Linux frame I don't see too many problems, but in Catalina Out, I always see:
May 30,2014 1:16:16 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 7626 ms May 30,2014 1:16:37 PM java.util.prefs.FileSystemPreferences$2 run WARNING: Could not create system preferences directory. System preferences are unusable. May 30,2014 1:16:55 PM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode WARNING: Could not lock System prefs. Unix error code -158097957. May 30,2014 1:16:55 PM java.util.prefs.FileSystemPreferences syncWorld WARNING: Couldn't flush system prefs: java.util.prefs.backingStoreException: Couldn't get file lock.
I did some digging / reading and derived the following points:
Administrators with root access must use drwxr-xr-x access to create the system preferences directory / etc / java/. systemPrefs.
Java is looking for / etc / java/. systemPrefs/. system. Lock and / etc / java/. systemPrefs/. systemRootModFile
Manually creating the above file (using "touch" to create an empty file) and its contained directory should be repairable The permission of the file should be 544, the permission of its directory should be 755, and the owner and group should be root
but
I'm not root. It's expensive for someone to run root. I have multiple users running JVMs. Does that mean I have to create these files and set permissions so that all users can access these permissions?
Has anyone encountered this problem if they have a simpler solution that I'm missing?
Solution
Set these settings for each user:
mkdir -p ~/.java/.systemPrefs mkdir ~/.java/.userPrefs chmod -R 755 ~/.java export JAVA_OPTS="-Djava.util.prefs.systemRoot=/home/user/.java -Djava.util.prefs.userRoot=/home/user/.java/.userPrefs" <run appl>
No directory is created, and some Java virtual machines default to / etc /
See Java – setting preferences backing store directory