# Elasticsearch 2.4.4 - compilation failure with groovy dynamic scripting which works fine in 2.1.1

**URL:** <https://discuss.elastic.co/t/elasticsearch-2-4-4-compilation-failure-with-groovy-dynamic-scripting-which-works-fine-in-2-1-1/92064>\
**Category:** Elasticsearch\
**Created:** [July 6, 2017, 9:31am UTC](https://discuss.elastic.co/t/elasticsearch-2-4-4-compilation-failure-with-groovy-dynamic-scripting-which-works-fine-in-2-1-1/92064 "2017-07-06T09:31:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavy](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pavy](https://discuss.elastic.co/u/pavy)\
**Post date:** [July 6, 2017, 9:31am UTC](https://discuss.elastic.co/t/elasticsearch-2-4-4-compilation-failure-with-groovy-dynamic-scripting-which-works-fine-in-2-1-1/92064/1 "2017-07-06T09:31:16Z")

</div>

Hi,  
I am using dynamic scripting with groovy in Elasticsearch 2.4.4. The script gives a compilation error, whereas the same script was working fine in Elasticsearch 2.1.1. I have verified the script complies fine in a groovy console.

The script works if the cast is removed but I would like to understand if there is any restriction in using the LinkedHashMap in groovy in 2.4.4, as I am aware that from 5.0 some restriction is made for security.

Error:  
caused\_by":{"type":"script\_exception","reason":"Error compiling script b065d53a6f4fa2969360ce7776fc0abfa1cd1f21","caused\_by":{"type":"multiple\_compilation\_errors\_exception","reason":"startup failed:\nb065d53a6f4fa2969360ce7776fc0abfa1cd1f21: 28: unable to resolve class LinkedHashMap

\_Code Snippet:

if (!found) {  
target.paths.add((LinkedHashMap)source);  
}\_

Any help in this regard is greatly appreciated.  
Thanks!  
Parvathy.

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [July 19, 2017, 6:31pm UTC](https://discuss.elastic.co/t/elasticsearch-2-4-4-compilation-failure-with-groovy-dynamic-scripting-which-works-fine-in-2-1-1/92064/2 "2017-07-19T18:31:04Z")

</div>

In 2.2.0, groovy was moved into an elasticsearch module (essentially a plugin that is installed automatically). Part of that was moving scripting security into each plugin, so each script engine handles its own whitelist of available classes. See [https://www.elastic.co/guide/en/elasticsearch/reference/2.4/modules-scripting-security.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/modules-scripting-security.html). Also, you might consider just casting to Map, as that should be available.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 16, 2017, 6:31pm UTC](https://discuss.elastic.co/t/elasticsearch-2-4-4-compilation-failure-with-groovy-dynamic-scripting-which-works-fine-in-2-1-1/92064/3 "2017-08-16T18:31:34Z")

</div>

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