# Unexpected token \['groovy'\] was expecting one of \[{\<EOF\>, ';'}\]

**URL:** <https://discuss.elastic.co/t/unexpected-token-groovy-was-expecting-one-of-eof/97256>\
**Category:** Elasticsearch\
**Created:** [August 16, 2017, 12:41pm UTC](https://discuss.elastic.co/t/unexpected-token-groovy-was-expecting-one-of-eof/97256 "2017-08-16T12:41:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JAYALAKSHMI](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@JAYALAKSHMI](https://discuss.elastic.co/u/JAYALAKSHMI)\
**Post date:** [August 16, 2017, 12:41pm UTC](https://discuss.elastic.co/t/unexpected-token-groovy-was-expecting-one-of-eof/97256/1 "2017-08-16T12:41:55Z")

</div>

We were using the below groovy script in 1.7.3 and now we are upgrading to 5.5.0 and the below groovy script is throwing "unexpected token ['groovy'] was expecting one of [{, ';'}]." message. Can you please help us in resolving it.

POST xxx\_index/yyyy\_type/\_bulk  
{"update":{"\_id":"as23f4", "\_retry\_on\_conflict" : 25}}  
{  
"script": "import groovy.json._;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx.\_source.ADC.addAll(object)",  
"params": {  
"newValues": "[{"ADC\_ID":1234,"ADC\_CODE":"00001234","ADC\_PRC":null}]"  
}  
}  
{"update":{"\_id":"av45hj78", "\_retry\_on\_conflict" : 25}}  
{  
"script": "import groovy.json._;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx.\_source.ADC.addAll(object)",  
"params": {  
"newValues": "[{"ADC\_ID":2345,"ADC\_CODE":"00002345","ADC\_PRC":45.8}]"  
}  
}

ERROR:

{  
"error": {  
"root\_cause": [  
{  
"type": "remote\_transport\_exception",  
"reason": "[dayrhebfmd001\_DEV\_550\_DATA][10.7.147.21:9264][indices:data/write/update[s]]"  
}  
],  
"type": "illegal\_argument\_exception",  
"reason": "failed to execute script",  
"caused\_by": {  
"type": "script\_exception",  
"reason": "compile error",  
"script\_stack": [  
"import groovy.json._;def jsonSlu ...",  
" ^---- HERE"  
],  
"script": "import groovy.json._;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx.\_source.XCD.addAll(object)",  
"lang": "painless",  
"caused\_by": {  
"type": "illegal\_argument\_exception",  
"reason": "unexpected token ['groovy'] was expecting one of [{, ';'}]."  
}  
}  
},  
"status": 400  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 16, 2017, 1:02pm UTC](https://discuss.elastic.co/t/unexpected-token-groovy-was-expecting-one-of-eof/97256/2 "2017-08-16T13:02:36Z")

</div>

> [@JAYALAKSHMI](#):
>
> “script”: "import groovy.json.;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx.\_source.XCD.addAll(object)”,
> 
> “lang”: “painless”,

Groovy is no longer the default scripting language, so it looks like it is being interpreted as painless, which [is replacing Groovy](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/modules-scripting-groovy.html) within Elasticsearch. You may therefore need to specify the scripting language in your request.

---

<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:** [September 13, 2017, 1:02pm UTC](https://discuss.elastic.co/t/unexpected-token-groovy-was-expecting-one-of-eof/97256/3 "2017-09-13T13:02:50Z")

</div>

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