22

I'm trying to use the new Java 7 Files.createSymbolicLink() method within Play! Framework, and I got the following exception:

RuntimeException occured : java.nio.file.FileSystemException: c:\work\foo\bar:
A required privilege is not held by the client.

This is my first encounter with Java's permission model, so I understand what's going on, but don't yet know how to fix it (I'd like to give the Controllers more permissions).

If anyone can answer here faster than I'll find the answer, me (and future readers) will be grateful.

ripper234
  • 222,824
  • 274
  • 634
  • 905
  • 4
    With Windows (W7), you can add a user to the list of who may create symbolic links (without disabling UAC) using security policies. Run "secpol.msc" and change "Security Settings|Local Policies|User Rights Assignment|Create symbolic links" – mins Jun 22 '14 at 17:20

2 Answers2

14

This isn't a problem with java permissions, but a problem with the operating system permissions. See FileSystemException.

The subclasses of FileSystemException are: AccessDeniedException, AtomicMoveNotSupportedException, DirectoryNotEmptyException, FileAlreadyExistsException, FileSystemLoopException, NoSuchFileException, NotDirectoryException, NotLinkException.

From AccessDeniedException:

Checked exception thrown when a file system operation is denied, typically due to a file permission or other access check. This exception is not related to the AccessControlException or SecurityException thrown by access controllers or security managers when access to a file is denied.

Matthew Farwell
  • 60,889
  • 18
  • 128
  • 171
  • BTW, when I googled for the stack trace, there were zero results on Google. So I'm the first one on the internet that had a problem with nio + UAC, and posted about it? – ripper234 Nov 22 '11 at 14:12
  • @ripper234 I doubt it, but you may be the first on stackoverflow. – Matthew Farwell Nov 22 '11 at 14:13
  • No, seriously, I got zero results everywhere. Try it right now, you'll only find this question: http://www.google.com/search?q=RuntimeException+occured+%3A+java.nio.file.FileSystemException+%22A+required+privilege+is+not+held+by+the+client.%22#sclient=psy-ab&hl=en&source=hp&q=RuntimeException+occured+%3A+java.nio.file.FileSystemException+%22A+required+privilege+is+not+held+by+the+client.%22&pbx=1&oq=RuntimeException+occured+:+java.nio.file.FileSystemException+%22A+required+privilege+is+not+held+by+the+client.%22 – ripper234 Nov 22 '11 at 14:27
  • It's interesting how it doesn't throw AccessDeniedException in this situation, but rather the generic FileSystemException. Kind of defeats the purpose of the specific subclass. – Hakanai Sep 13 '12 at 23:01
11

After seeing this answer, and remembering I am running on Windows 7 with UAC, I understand this is a Windows issue.

  1. Nothing can be done from within Java to make this go away.
  2. I should be able to turn off UAC for Play specifically somehow (run as admin etc...), but the question isn't really related to Play (or java permissions) at all.

Indeed, when running:

runas /noprofile /user:Administrator cmd
cd c:\myapp
play run

everything works well.

Community
  • 1
  • 1
ripper234
  • 222,824
  • 274
  • 634
  • 905
  • 1
    https://stackoverflow.com/questions/23217460/how-to-create-soft-symbolic-link-using-java-nio-files – gkns Mar 05 '19 at 10:10