# After upgrade from ES-2.1.1 to ES-2.2.0 groovy scripting is broken

**URL:** <https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977>\
**Category:** Elasticsearch\
**Created:** [February 4, 2016, 4:28pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977 "2016-02-04T16:28:36Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [February 4, 2016, 4:28pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/1 "2016-02-04T16:28:36Z")

</div>

trying a test-query after upgrading from ES-2.1.1 to ES-2-2-0

`POST smd_*/_search { "query": { "match_all": {} }, "script_fields": { "test": { "script": { "inline": "1 + 1" }}}}`  
brings an error:

`"root_cause": [{ "type": "illegal_argument_exception", "reason": "script_lang not supported [groovy]" } ],`

while the same request to the 2.1.1 instance works as expected.

elasticsearch.yml has

`script.inline: true script.indexed: true script.file: true`

the logfile does not show anything unusual. the word groovy only appears in the errormessage shown above.

groovy jars location differ (I used the zip version under centos, jdk1.8.0\_65):

`[elastic@localhost ~]$ find . -name '_groovy_'

./elasticsearch-2.2.0/modules/lang-groovy  
./elasticsearch-2.2.0/modules/lang-groovy/lang-groovy-2.2.0.jar  
./elasticsearch-2.2.0/modules/lang-groovy/groovy-all-2.4.4-indy.jar

./elasticsearch-2.1.1/lib/groovy-all-2.4.4-indy.jar`

I tried also to store the script as file in the script directory: did not help. Disabling the java security manager also did not change anything. So: any idea what I should do?

Many thanks for help.

---

<div class="post-metadata">

**Author:** ![Jayme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayme/32/6008_2.png) [@Jayme](https://discuss.elastic.co/u/Jayme)\
**Post date:** [February 4, 2016, 4:55pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/2 "2016-02-04T16:55:50Z")

</div>

I think you need to override them specifically again for groovy  
script.engine.groovy.inline.search: true  
script.engine.groovy.inline.update: true  
script.engine.groovy.inline.mapping: true

Regards  
Jayme

---

<div class="post-metadata">

**Author:** ![ymek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ymek/32/7588_2.png) [@ymek](https://discuss.elastic.co/u/ymek)\
**Post date:** [February 4, 2016, 5:12pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/3 "2016-02-04T17:12:00Z")

</div>

I'm having the same issue. Unfortunately, Jayme's suggestion doesn't fix the problem. Were it simply a configuration issue, the "reason" messaging would differ, pointing out that groovy is disabled for requests of this type.

Relevant bits of my config:

```
script.inline: true
script.indexed: true
script.file: true

script.engine.groovy.inline: true
script.engine.groovy.inline.search: true
script.engine.groovy.inline.update: true
script.engine.groovy.inline.mapping: true
```

---

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [February 4, 2016, 6:35pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/4 "2016-02-04T18:35:30Z")

</div>

Thank you Jayme.  
I changed my elasticsearch.yml; but the behaviour is still the same. No change in reported errors in logfile.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 4, 2016, 7:41pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/5 "2016-02-04T19:41:32Z")

</div>

Perhaps there is something written up here:  
[https://www.elastic.co/guide/en/elasticsearch/reference/2.2/modules-scripting-security.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/modules-scripting-security.html)

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian/32/54874_2.png) [@brian](https://discuss.elastic.co/u/brian)\
**Post date:** [February 4, 2016, 7:48pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/6 "2016-02-04T19:48:33Z")

</div>

After I updated from 2.1.1 to 2.2.0 I see this error when trying to use scripts.  
{"type":"illegal\_argument\_exception","reason":"Unable to find on disk file script [closest\_listing] using lang [groovy]"}

closest\_lisitng.groovy is the script located at /etc/elasticsearch/scripts

Was working fine on 2.1.1.

Any ideas?

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian/32/54874_2.png) [@brian](https://discuss.elastic.co/u/brian)\
**Post date:** [February 4, 2016, 8:01pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/7 "2016-02-04T20:01:29Z")

</div>

For my case [https://www.elastic.co/guide/en/elasticsearch/reference/2.x/modules-scripting-security.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.x/modules-scripting-security.html) was causing the issue. I was trying to import some restricted classes.  
I added:

> ```
> grant {
> permission org.elasticsearch.script.ClassPermission "*"; // allow all (disables filtering basically)
> };
> 
> ```

to the java.policy file and restarted elasticsearch. Scripts worked fine after that.

---

<div class="post-metadata">

**Author:** ![mumpi](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mumpi](https://discuss.elastic.co/u/mumpi)\
**Post date:** [February 5, 2016, 4:31am UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/8 "2016-02-05T04:31:49Z")

</div>

sorry. Was much simpler: I did not check that ES has now a new dir modules and my setup did not link to it. Grovy Scripting is working now.

---

<div class="post-metadata">

**Author:** ![bdelmas](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bdelmas](https://discuss.elastic.co/u/bdelmas)\
**Post date:** [February 5, 2016, 12:00pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/9 "2016-02-05T12:00:14Z")

</div>

Is it the right solution? I was doing [this simple tutorial](https://www.digitalocean.com/community/tutorials/how-to-interact-with-data-in-elasticsearch-using-crud-operations) with a fresh brew install then doing a few command lines, when I had the same error at this command line:

```
curl -XPOST "http://localhost:9200/playground/equipment/1/_update" -d '{ "script": "ctx._source.quantity += step", "params": { "step": 1 } }'
```

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [February 6, 2016, 3:27pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/10 "2016-02-06T15:27:41Z")

</div>

> Is it the right solution? I was doing this simple tutorial with a fresh brew install

Reinstall from Homebrew again; the first version of the updated formula for Elasticsearch 2.2.0 did not install the `modules` folder from the distribution but it does [now](https://github.com/Homebrew/homebrew/pull/48843). I'm sorry!

---

<div class="post-metadata">

**Author:** ![bdelmas](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bdelmas](https://discuss.elastic.co/u/bdelmas)\
**Post date:** [February 7, 2016, 10:48pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/11 "2016-02-07T22:48:55Z")

</div>

That was quick thanks!

---

<div class="post-metadata">

**Author:** ![FisherKing](https://avatars.discourse-cdn.com/v4/letter/f/919ad9/32.png) [@FisherKing](https://discuss.elastic.co/u/FisherKing)\
**Post date:** [February 12, 2016, 1:11am UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/12 "2016-02-12T01:11:59Z")

</div>

Can anyone tell me how to enable it for an embedded ElasticSearch?  
Groovy worked without any problems in 2.1.1 ( Only "script.engine.groovy.inline.search", "true" was needed in my case).

I added all the Jars from the new module directories.

My settings look like this:

Settings.settingsBuilder().put("script.file" , "true").put("script.indexed" , "true").put("script.inline" , "true"). put( "script.engine.groovy.inline.search", "true"). put( "script.engine.groovy.inline.update", "true"). put( "script.engine.groovy.inline.mapping", "true")

I also tried to set a java.policy file.

I always see this error: IllegalArgumentException[script\_lang not supported [groovy]

Do I have to manually load the Groovy module or something like that?

---

<div class="post-metadata">

**Author:** ![David\_Baird](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@David\_Baird](https://discuss.elastic.co/u/David_Baird)\
**Post date:** [February 12, 2016, 12:23pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/13 "2016-02-12T12:23:53Z")

</div>

+1 on this one. I'm running embedded in a grails app, so groovy is already on the classpath. I get a (non-fatal) stack trace when I create the node: script\_lang not supported [groovy] when it encounters my .groovy file in the script dir. It used to work just fine on 1.7.x. I tried adding an inline script field using the search builder, but it fails in a similar way, claiming "script\_lang not supported [groovy]". Any help would be greatly appreciated.

\*\*\* Update: I think the reason why it doesn't work is because groovy as a scripting language has been pulled out into the 'lang-groovy' plugin (see [https://github.com/elastic/elasticsearch/pull/13834](https://github.com/elastic/elasticsearch/pull/13834)). This is a problem for embedded nodes because there doesn't seem to be a way to install plugins using the NodeBuilder (see [Add plugins from classpath in embedded Elasticsearch client node](https://discuss.elastic.co/t/add-plugins-from-classpath-in-embedded-elasticsearch-client-node/36269)). I think in the short term 2.1.2 still works as it did before, so I'll be rolling back to that version for now.

---

<div class="post-metadata">

**Author:** ![FisherKing](https://avatars.discourse-cdn.com/v4/letter/f/919ad9/32.png) [@FisherKing](https://discuss.elastic.co/u/FisherKing)\
**Post date:** [February 13, 2016, 4:22pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/14 "2016-02-13T16:22:18Z")

</div>

With the help of one of your links I solved the problem with Groovy.

This code should work for ES 2.2 (Java 8 is needed!):

```
    Settings settings = Settings.settingsBuilder(). put( "script.engine.groovy.inline.search", "true") ...    
    Environment env = new Environment(settings);        

    Collection<Class<? extends Plugin>> classpathPlugins = Collections.singletonList(GroovyPlugin.class);        
           
    node = new MockNode(env, Version.CURRENT, classpathPlugins );        
        
    node.start();

import java.util.Collection;
import org.elasticsearch.Version;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.Node;
import org.elasticsearch.plugins.Plugin;

public class MockNode extends Node {

    // these are kept here so a copy of this MockNode can be created, since Node does not store them
    private Version version;
    private Collection<Class<? extends Plugin>> plugins;

    public MockNode(Environment env, Version version, Collection<Class<? extends Plugin>> classpathPlugins)
    {          
        super(env, version, classpathPlugins);
        this.version = version;
        this.plugins = classpathPlugins;
    }

    public Collection<Class<? extends Plugin>> getPlugins() {
        return plugins;
    }

    public Version getVersion() {
        return version;
    }
}
```

---

<div class="post-metadata">

**Author:** ![cwinkler](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@cwinkler](https://discuss.elastic.co/u/cwinkler)\
**Post date:** [February 26, 2016, 7:15am UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/15 "2016-02-26T07:15:56Z")

</div>

The workaround posted by @FisherKing works but it seems odd to me that there is no official and straightforward way of doing this.  
Is this issue to be fixed in an upcoming release?

---

<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:** [July 5, 2017, 11:13pm UTC](https://discuss.elastic.co/t/after-upgrade-from-es-2-1-1-to-es-2-2-0-groovy-scripting-is-broken/40977/16 "2017-07-05T23:13:22Z")

</div>


