3

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:

  1. While i can get/set preferences on runtime, The preferences are getting deleted each time I kill the program and run it again.

  2. 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);
    ...
});
OmriSoudry
  • 361
  • 3
  • 13

1 Answers1

4

I solved the issue with the following:

sudo chmod -R 775 ~/.java/
sudo chown -R username:root ~/.java/

Just doing the first command wasn't enough.

inkalchemist1994
  • 193
  • 1
  • 10