I'm running a Java Spark server on a Linux machine, and I'm trying to store user preferences and I'm having two major problems:
While i can get/set preferences on runtime, The preferences are getting deleted each time I kill the program and run it again.
Sometimes I receive this error (which might have to do with users requesting different pages on the same time):
Exception in thread "Timer-0" java.lang.SecurityException: Could not lock User prefs. Lock file access denied.
My code looks like this:
...
prefs = Preferences.userRoot().node(PREFS_NAME);
...
get("/sample/reset", (req, res) -> {
prefs.put("bgimg", "test");
...
});
get("/sample/", (req, res) -> {
String bgImgPath = prefs.get("bgimg",BACKGROUND_IMAGE_PATH);
...
});