org.codehaus.groovy.GroovyBugError: BUG! exception in phase 'semantic analysis' in elasticsearch 5.6.10 cluster log

I am executing from my java application the following code using elasticsearch java api 5.6.10, I am execute an update using and use the groovy script inline

bulkRequest.add(
                        transportClient
                                .prepareUpdate(indexName, ResultType.RESULT.toString(), (String) obj.get("id"))
                                .setScript(new Script(ScriptType.INLINE,"groovy",script,params))
                                .setScriptedUpsert(true)
                                .setRetryOnConflict(configuration.db().saveMaxRetry())
                                .setUpsert(obj));
            }

        BulkResponse response = bulkRequest.execute().actionGet();

I am receiving the following error in elasticsearch cluster log:

Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_171]
        at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_171]
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_171]
        at java.lang.Class.checkMemberAccess(Class.java:2348) ~[?:1.8.0_171]
        at java.lang.Class.getDeclaredFields(Class.java:1915) ~[?:1.8.0_171]
        at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:356) ~[?:?]
        at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:265) ~[?:?]
        at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:1004) ~[?:?]
        at org.codehaus.groovy.ast.ClassNode.getUnresolvedSuperClass(ClassNode.java:999) ~[?:?]
        at org.codehaus.groovy.control.ResolveVisitor.checkCyclicInheritence(ResolveVisitor.java:1284) ~[?:?]
        at org.codehaus.groovy.control.ResolveVisitor.checkCyclicInheritence(ResolveVisitor.java:1284) ~[?:?]
        at org.codehaus.groovy.control.ResolveVisitor.checkCyclicInheritence(ResolveVisitor.java:1284) ~[?:?]
        at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1261) ~[?:?]
        at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:178) ~[?:?]
        at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:651) ~[?:?]
        at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) ~[?:?]
        ... 38 more

This problem was fixed adding the followings lines:

  permission java.lang.RuntimePermission "accessDeclaredMembers";
  permission java.lang.RuntimePermission "setFactory";
  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";

in /usr/share/elasticsearch/modules/lang-groovy/plugin-security.policy

solved in https://stackoverflow.com/questions/52406677/org-codehaus-groovy-groovybugerror-bug-exception-in-phase-semantic-analysis

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