Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java system preferences under different users in linux

I'm trying to run multiple jvms (including tomcat) under different users on one linux box. I'm not seeing too many issues, but in catalina.out I keep seeing this:

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 deduced the following:

An administrator with root access must create the system preferences directory /etc/.java/.systemPrefs with drwxr-xr-x access.

Java's looking for /etc/.java/.systemPrefs/.system.lock and /etc/.java/.systemPrefs/.systemRootModFile

Manually creating the above files (use "touch" to create empty files) and their containing directories should fix. Rights to the files should be 544, rights to their directories should be 755, owner and group are root for all.

But

I am not root, getting someone to run root is expensive and I have multiple users running jvms, does that mean i have to create those files and set up permissions just so that all users have access with those privileges?

Has anyone ever run into this issue and if they have is there a simpler solution i am missing?

like image 589
niken Avatar asked May 30 '14 17:05

niken


People also ask

Where are Java preferences stored on Linux?

On Linux systems, the system preferences are typically stored at java-home/. systemPrefs in a network installation, or /etc/. java/. systemPrefs in a local installation.

What is preference in Java?

A node in a hierarchical collection of preference data. This class allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store.

What is Userprefs?

The userprefs. xml file contains a series of ParameterName elements that contain a ParameterValue element. The names of the parameters you can set are contained in the ParameterName elements. Enter the value for these parameters in the associated ParameterValue elements.


1 Answers

Set these settings per 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>

Without creating the directories, some Java virtual machines default to /etc/.

See also: Java - Setting Preferences backingstore directory

like image 146
niken Avatar answered Oct 07 '22 19:10

niken