I'm trying to run JUnit tests using IntelliJ Idea 11.1. But the tests are giving different AccessControlExceptions. One of them are below. But these tests run without a problem in Eclipse.
Exception in thread "main" java.security.AccessControlException: access denied (java.lang.RuntimePermission setIO)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.System.checkIO(System.java:225)
at java.lang.System.setOut(System.java:147)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Do I need to set special permissions of some kind for the IDEA test runner? If so how?
I just ran into this problem myself, to at least get things running, I copied the java.policy
file from <jdk>/jre/lib/security
and added the following permissions in the default grant
to get the tests running under IntelliJ IDEA 2016.2:
// To get tests working under IntelliJ 2016.2
permission java.util.PropertyPermission "idea.launcher.bin.path", "read";
permission java.lang.RuntimePermission "loadLibrary.C:\\Program Files (x86)\\JetBrains\\IntelliJ IDEA 2016.2\\bin\\breakgen64.dll";
permission java.util.PropertyPermission "idea.launcher.port", "read";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.util.PropertyPermission "idea.is.junit5", "read";
permission java.net.SocketPermission "127.0.0.1:*", "connect,resolve";
permission java.util.PropertyPermission "user.home", "read";
permission java.io.FilePermission "C:\\Users\\Mark\\junit.properties", "read";
permission java.lang.RuntimePermission "setIO";
permission java.io.FilePermission "C:\\Users\\Mark\\AppData\\Local\\Temp\\*", "read";
permission java.lang.RuntimePermission "accessDeclaredMembers";
You will need to change some of the paths to suit your specific user needs. With these changes I am not yet completely done: I still seem to be missing some permissions specific to my own code (specifically: reading a number of property files from my own code).
Create a file C:\utils\grant_all.policy with content
// Grant everyone all permissions:
grant {
permission java.security.AllPermission;
};
and add in the debug configuration in IntelliJ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With