JDK-8038489 : WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2014-03-25
  • Updated: 2015-12-30
  • Resolved: 2014-03-27
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)



ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
The warning:
  Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
is logged. This happens when accessing the userRoot. The static system root is also created at that time and causes the warning log.
See:
  WindowsPreferrencesFactory

This happens at least for fresh jre installations of jre 1.7.0_21 and higher. Installation of older jre versions create the key
  HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs
versions 1.7.21 and later do NOT.
When upgrading from an older version, the existing HKLM key is not removed. That is why it only occurs on fresh installations.
With an existing HKLM key (from the installer) no warnings are generated.


REGRESSION.  Last worked in version 7u13

ADDITIONAL REGRESSION INFORMATION: 
JRE 1.8.0 installer does NOT create the HKLM Prefs key
JRE 1.7.0_21 (and higher) installer does NOT create the HKLM Prefs key
JRE 1.7.0_13 installer does create the HKLM Prefs key
_15 and _17 not tested.



ERROR MESSAGES/STACK TRACES THAT OCCUR :
Mar 25, 2014 11:19:08 AM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package Bugs;

import java.util.prefs.Preferences;

public class PrefsWarning {

  void findPrefs() {
    Preferences prefs = Preferences.userRoot();
//    Preferences prefs = Preferences.userNodeForPackage(this.getClass());
  }

  public static void main(String[] args) {
    PrefsWarning pw = new PrefsWarning();
    pw.findPrefs();
  }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Crreate Prefs key manually
- or -
Install (very) old jre and upgrade it to a newer one



Comments
I wasn't able to reproduce this. I did a fresh install of JRE 7u51. C:\Users\sc87771>"C:\Program Files (x86)\Java\jre7\bin\java" PrefsWarning <no warning logged>
27-03-2014

This might need the installer team to comment, it sounds like the registry settings changed in one of the 7 update releases. In any case, we also need to understand why the preferences API should depend on this (it should just work even if we start out with a tar ball)
26-03-2014