获取 FileSystemException“客户端不拥有所需的权限”在 Play 框架中使用 Files.createSymbolicLink

发布于 2024-12-17 13:49:18 字数 545 浏览 2 评论 0原文

我正在尝试使用新的 Java 7 Files.createSymbolicLink() 方法!框架,我得到了以下异常:

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

这是我第一次遇到Java的权限模型,所以我明白发生了什么,但还不知道如何修复它(我想给予控制器更多权限)。

如果有人能比我更快地找到答案,我(和未来的读者)将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

执笏见 2024-12-24 13:49:18

这不是java权限的问题,而是操作系统权限的问题。请参阅 FileSystemException

FileSystemException 的子类有:AccessDeniedException、AtomicMoveNotSupportedException、DirectoryNotEmptyException、FileAlreadyExistsException、FileSystemLoopException、NoSuchFileException、NotDirectoryException、NotLinkException。

来自 AccessDeniedException:

当文件系统操作被拒绝时引发的已检查异常,通常是由于文件权限或其他访问检查所致。
此异常与拒绝访问文件时访问控制器或安全管理器引发的 AccessControlException 或 SecurityException 无关。

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.

梦里兽 2024-12-24 13:49:18

看到这个答案后,并记住我正在 Windows 7 上运行 UAC,我知道这是一个 Windows 问题。

  1. Java 内部无法采取任何措施来消除这种情况。
  2. 我应该能够以某种方式专门关闭 Play 的 UAC(以管理员身份运行等...),但问题与 Play(或 java 权限)根本无关。

事实上,跑步时:

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

一切正常。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文