Search code examples
lockingnexussonatype

Nexus Repo - could not lock user prefs


I'm running Sonatype Nexus 3 inside a docker container, with the following startup command:

docker run -d -p 80:8081 --ulimit nofile=65536:65536 --name nexus -v nexus-data:/nexus-data -e INSTALL4J_ADD_VM_PARAMS="-Xms4g -Xmx4g -XX:MaxDirectMemorySize=6717m  -Djava.util.prefs.userRoot=${NEXUS_DATA}/javaprefs" sonatype/nexus3

After updating the docker image version from 3.30.0 to 3.40.1, I keep getting the following warnings regarding user prefs.

2022-07-18 13:14:45,860+0000 WARN  [Timer-0] *SYSTEM java.util.prefs - Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
2022-07-18 13:15:15,860+0000 WARN  [Timer-0] *SYSTEM java.util.prefs - Could not lock User prefs.  Unix error code 2.

As you can see from the startup command, the user prefs directory is inside the docker volume and at directory /nexus-data/javaprefs . I have tried looking for existing locks inside the directory, but found none. I've also tried completely deleting the directory and saw that the warning still came up and the folder itself wasn't being created by Nexus.

I honestly don't even know if this is an important issue or not, since there is little to no documentation about the user preferences folder.

Even a way to turn off the warning log which fires every 30s would be useful.

----UPDATE----

I've tried doing a clean installation of Nexus through Docker, following the simple instructions inside the github sonatype nexus3 docker repository, and still find these warnings.

I even tried on a different OS (Windwos instead of linux, through Docker Desktop) and with and without a volume for /nexus-data.

At this point I believe it to be a bug in a newer Nexus version.


Solution

  • TLDR: Adding -Djava.util.prefs.userRoot=/nexus-data/javaprefs should solve the problem, assuming the nexus data directory is at /nexus-data/.

    Just had the same issue after upgrading from 3.38.1 to 3.42.0. After some investigation found that indeed the java.util.prefs.userRoot property got lost somewhere between those versions. The default value in the vanilla Nexus 3.38.1 is /nexus-data/javaprefs.