Permission denied error in plugin for ES 2.2.0

Hi All,
I am trying to write a plugin for ES 2.2.0. When I start elasticsearch with plugin installed, this is what I get -

Likely root cause: access denied ("" "createMBeanServer")
at java.lang.SecurityManager.checkPermission(
at com.yammer.metrics.reporting.JmxReporter.(
at com.yammer.metrics.reporting.JmxReporter.startDefault(
at com.yammer.metrics.Metrics.(

This is my plugin-security.policy file -

grant {
permission "createMBeanServer";

I have seen a similar exception in cloud-aws plugin as well, so I am not sure if this is supposed to work. Am I missing something?


1 Like


We have similar problem with our plugins,
when trying to run any unit tests, we get the following errors: access denied ("org.elasticsearch.ThreadPermission" "modifyArbitraryThreadGroup")

at java.lang.SecurityManager.checkPermission(
at org.elasticsearch.SecureSM.checkThreadGroupAccess(
at org.elasticsearch.SecureSM.checkAccess(
at java.lang.ThreadGroup.checkAccess(
at java.lang.ThreadGroup.getParent(
at com.carrotsearch.randomizedtesting.Threads.getTopThreadGroup(
at com.carrotsearch.randomizedtesting.Threads.getAllThreads(
at com.carrotsearch.randomizedtesting.ThreadLeakControl.<init>(
at com.carrotsearch.randomizedtesting.RandomizedRunner.runSuite(
at com.carrotsearch.randomizedtesting.RandomizedRunner.access$200(
at com.carrotsearch.randomizedtesting.RandomizedRunner$

and access denied ("java.lang.RuntimePermission" "setDefaultUncaughtExceptionHandler")
at java.lang.SecurityManager.checkPermission(
at java.lang.Thread.setDefaultUncaughtExceptionHandler(
at com.carrotsearch.randomizedtesting.RandomizedRunner.runSuite(

We tried to follow instructions by adding a plugin-security.policy in src/main/plugin-metadata (we tried also in src/main/resources or src/test/resources) with the following rules, without any luck:

grant {
permission org.elasticsearch.ThreadPermission "modifyArbitraryThreadGroup";
permission java.lang.RuntimePermission "setDefaultUncaughtExceptionHandler";

I was able to get rid of the error today...
There are two things that need to be done - one is to ensure proper permissions in plugin-security.policy and second is to wrap your code which needs special permissions with


Here is a snippet from ES help -

// ES permission you should check before doPrivileged() blocks
import org.elasticsearch.SpecialPermission;

SecurityManager sm = System.getSecurityManager();
if (sm != null) {
  // unprivileged code such as scripts do not have SpecialPermission
  sm.checkPermission(new SpecialPermission());
  // sensitive operation

More info here -


Thanks Madhav for the info,

the issue however does not come from my code, but from the elasticsearch test framework.
We managed to progress a bit. The permission issue we had with com.carrotsearch.randomizedtesting was due to having the com.carrotsearch.randomizedtesting dependency not set to version 2.2.0. After using this dependency in my application, the permission errors were gone.

However, we stumble upon a new permission issue (see below). Looks like elasticsearch test framework does not have file permission policy for my target test directory. From what I understand, permissions defined in plugin-security.policy are granted only to the plugin itself, not to elasticsearch test framework. The only way I found to make it work is to specify my own policy at runtime using which does not sound right. access denied ("" "./target/elasticsearch-test/data/SUITE-CHILD_VM=[0]-CLUSTER_SEED=[-3368555408586290560]-HASH=[4D23AA0D8173]-cluster/nodes/0" "write")

at java.lang.SecurityManager.checkPermission(
at java.lang.SecurityManager.checkWrite(
at sun.nio.fs.UnixPath.checkWrite(
at sun.nio.fs.UnixFileSystemProvider.createDirectory(
at org.apache.lucene.mockfile.FilterFileSystemProvider.createDirectory(
at org.apache.lucene.mockfile.FilterFileSystemProvider.createDirectory(
at org.apache.lucene.mockfile.FilterFileSystemProvider.createDirectory(
at org.apache.lucene.mockfile.FilterFileSystemProvider.createDirectory(
at java.nio.file.Files.createDirectory(
at java.nio.file.Files.createAndCheckIsDirectory(
at java.nio.file.Files.createDirectories(
at org.elasticsearch.env.NodeEnvironment.<init>(
at org.elasticsearch.node.Node.<init>(
at org.elasticsearch.node.MockNode.<init>(
at org.elasticsearch.test.InternalTestCluster.buildNode(
at org.elasticsearch.test.InternalTestCluster.reset(
at org.elasticsearch.test.InternalTestCluster.beforeTest(
at org.elasticsearch.test.ESIntegTestCase.beforeInternal(
at org.elasticsearch.test.ESIntegTestCase.before(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(
at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(
at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(
at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(
at org.apache.lucene.util.TestRuleSetupTeardownChained$1.evaluate(
at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(
at org.apache.lucene.util.TestRuleThreadAndTestName$1.evaluate(
at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(
at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(

The plugin help mentions this -

If you are using the elasticsearch Maven build system, place this file in src/main/plugin-metadata and it will be applied during unit tests as well.

Also take a look at this PR for security settings -

Hope this helps!


Thanks Madhav for the help, but I found a solution to my problem.

For other people encountering the same issue,
the cause of the FilePermission error was due to our custom node setting in our unit tests:

  protected Settings nodeSettings(int nodeOrdinal) {
    return settingsBuilder()
      .put("", "./target/elasticsearch-test/data/")

Removing this custom setting solved the issue.