AccessControlException: access denied for a readable file

你说的曾经没有我的故事 提交于 2019-12-11 17:07:55

问题


I have this file:

➜ ✗ ll ltr /Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh

-rwxrwxrwx  1 eladb  eng   882B Jun 11 16:38 /Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh

I try to read it from java:

        new FileInputStream(new File("/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh"));

but i get an error:

java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/eladb/WorkspaceQa/sdk-service/src/main/resources/convert_conditions.sh" "read")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_91]
    at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_91]
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_91]
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888) ~[?:1.8.0_91]
    at java.io.FileInputStream.<init>(FileInputStream.java:127) ~[?:1.8.0_91]

how come, as everyone has a read permission to that file?


回答1:


The operating system's file permissions have nothing to do with it. See the stack trace, or indeed the Javadoc of the exception. This exception comes from the Java security manager, not the operating system. You are running under a security manager (why?) and you haven't granted yourself permission to access that file in your .policy file.



来源:https://stackoverflow.com/questions/44526263/accesscontrolexception-access-denied-for-a-readable-file

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