Analyzer plugin - java.lang.RuntimePermission issue

Hi,

I'm writing analyzer plugin for es 5.2.1 on ubutnu 14.04.

After restart, when cluster is green and the plugin is loaded,

I run simple analyze command for testing and I get this error..

curl -XGET 'localhost:9200/_analyze?pretty' -d '
{
"analyzer" : "my_spanish_analyzer",
"text" : "this is a test"
}'

there is no response and the cluster performing restart...

...
2017-03-14 17:26:44.146381500 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_121]
2017-03-14 17:26:44.146385500 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_121]
2017-03-14 17:26:44.146386500 at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
2017-03-14 17:26:44.146387500 Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
2017-03-14 17:26:44.146388500 at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_121]
2017-03-14 17:26:44.146391500 at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_121]
...

(getClassLoader is a part from my analyzer code )

Any ideas ?

Thanks.

Read https://www.elastic.co/guide/en/elasticsearch/plugins/current/plugin-authors.html

1 Like

YAY !!!
Thanks David !!!

Fixed with plugin-security.policy file at plugin-metadata dir :

grant {
permission java.io.FilePermission "MY_PATH", "read";
};

And:

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

    AccessController.doPrivileged( SOME_CODE... );

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.