Getting FileSystemException “A required privilege is not held by the client” using Files.createSymbolicLink in Play Framework

青春壹個敷衍的年華 提交于 2019-11-30 00:31:18

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8228030/getting-filesystemexception-a-required-privilege-is-not-held-by-the-client-usi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!