java.security.AccessControlException when using Ant
Post date: Jul 13, 2014 1:40:25 AM
Symptom: When Mongoser try to connect to MongoDB, the following Warning appears.
WARNING: jmx registration error: java.security.AccessControlException:
access denied (javax.management.MBeanTrustPermission register) continuing...
Fix: Must grant security permission to JVM
Create a file name "security.policy" with the following content
grant { permission javax.management.MBeanTrustPermission "register"; };
Then tell JVM about this file, from cmd line
java -Djava.security.policy=<path/to/security.policy>
or from Ant's build.xml
<target name="run" depends="compile" description="run" >
<java classname="com.andreig.jetty.SimpleMongodbServer" classpathref="project.classpath" fork="true">
<jvmarg line="-Djava.security.policy=security.policy"/>
</java>
</target>
Note that forking is needed for the argument to be effective.
Alternatively, it seems that one can modify the behavior of JVM permanently by adding
permission javax.management.MBeanTrustPermission "register";
to %JAVA_HOME%\jre\lib\security\java.policy