Name: nt126004 Date: 12/17/2001
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
FULL OPERATING SYSTEM VERSION : Linux 2.2.18, SuSE Linux 7.1
(i386), glibc-2.2-7
A DESCRIPTION OF THE PROBLEM :
The problem occures due to the access rights of the file
system. When a java application is started under an account
other than the root account and has to create the system
preferences backing store, it tries to write in the part of
the file system where only root has write privilege.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Remove all .java directories in /etc or */java//
directories, if any.
2. Run the test programm under an account other than the
root account. If the line packagePrefs.sync() is uncommented
this will throw the BackingStoreException.
3. Log in as root, run the program again. The .java
directory is created.
EXPECTED VERSUS ACTUAL BEHAVIOR :
In the Preferences API Documentation it says:
"The user of this class needn't be concerned with details of
the backing store."
This would mean the user should not need to run the
application with special access privileges as this is
normally not necessary. Users might not even have the
possibility to switch to the root account. In this case they
have to bother writing their own PreferencesFactory.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Under an account other than the root account:
java -cp classes prefs.test.PreferencesTestProgram
got system preferences...
Put key-value pair
java.util.prefs.BackingStoreException:
/usr/lib/j2sdk1.4.0/jre/.systemPrefs/prefs/test create failed.
at
java.util.prefs.FileSystemPreferences$12.run(FileSystemPreferences.java:569)
at
java.security.AccessController.doPrivileged(Native Method)
at
java.util.prefs.FileSystemPreferences.writeBackCache(FileSystemPreferences.java:565)
at
java.util.prefs.FileSystemPreferences.syncSpiPrivileged(FileSystemPreferences.java:737)
at
java.util.prefs.FileSystemPreferences.access$2300(FileSystemPreferences.java:35)
at
java.util.prefs.FileSystemPreferences$17.run(FileSystemPreferences.java:707)
at
java.security.AccessController.doPrivileged(Native Method)
at
java.util.prefs.FileSystemPreferences.syncSpi(FileSystemPreferences.java:705)
at
java.util.prefs.AbstractPreferences.sync2(AbstractPreferences.java:1314)
at
java.util.prefs.AbstractPreferences.sync(AbstractPreferences.java:1305)
at
java.util.prefs.FileSystemPreferences.sync(FileSystemPreferences.java:684)
at
prefs.test.PreferencesTestProgram.<init>(PreferencesTestProgram.java:27)
at
prefs.test.PreferencesTestProgram.main(PreferencesTestProgram.java:46)
under root account:
java -cp classes prefs.test.PreferencesTestProgram
17.12.2001 10:22:59 java.util.prefs.FileSystemPreferences$2 run
INFO: Recreated system preferences directory in
/etc/.java/.systemPrefs
got system preferences...
Put key-value pair
Retrieving value: testValue
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
* PreferencesTestProgram.java
*/
package prefs.test;
import java.util.prefs.*;
public class PreferencesTestProgram
{
public PreferencesTestProgram()
{
try
{
Preferences packagePrefs =
Preferences.systemNodeForPackage(this.getClass());
System.out.println("got system preferences...");
packagePrefs.put("testKey", "testValue");
System.out.println("Put key-value pair");
packagePrefs.sync();
String value = packagePrefs.get("testKey", "defaultTestValue");
System.out.println("Retrieving value: " + value);
}
catch (BackingStoreException bse)
{
bse.printStackTrace(System.out);
}
}
public static void main(String[] args)
{
PreferencesTestProgram ptp = new PreferencesTestProgram();
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
If you are able to log in as root but you don't want to run
your applications with root privileges: Create the directory
/etc/.java and change the owner to be you or create a user
like "javaapps" and make this the owner of the .java
directory. Run the application under this account.
(Review ID: 137443)
======================================================================