# Script plugin parameters throw IOException: can not write type

**URL:** <https://discuss.elastic.co/t/script-plugin-parameters-throw-ioexception-can-not-write-type/86092>\
**Category:** Elasticsearch\
**Created:** [May 17, 2017, 11:44am UTC](https://discuss.elastic.co/t/script-plugin-parameters-throw-ioexception-can-not-write-type/86092 "2017-05-17T11:44:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hector\_R](https://avatars.discourse-cdn.com/v4/letter/h/df705f/32.png) [@Hector\_R](https://discuss.elastic.co/u/Hector_R)\
**Post date:** [May 17, 2017, 11:44am UTC](https://discuss.elastic.co/t/script-plugin-parameters-throw-ioexception-can-not-write-type/86092/1 "2017-05-17T11:44:19Z")

</div>

Hi all,

we are upgrading elastic search from 2.3.3 to 5.4.0 and facing a problem. We have a plugin with a native script registered. The script field is added like this to the search request:

```
ImmutableMap<String, Object> params = ImmutableMap.<String, Object>of(
                "command", command,
                "session", new XContentSession(EvaluatorSessionElement.buildSession(binding, getSelections(), elementConstraintMap, false))
        );
                
requestBuilder.addScriptField("result", new Script(ScriptType.INLINE, "native", "tql-evaluator", params));

```

XContentSession is a class that implements ToXContent.

In 2.3.3, although the second parameter was a XContentSession, it was passed to the script as a Map and there we converted it to XContentSession. Upgrading to 5.4.0, it seems the parameter is passed as a XContentSession, which seems good and better, but then when executing the search request we got an exception like:

! java.io.IOException: can not write type [class com.artisol.dolabra.es.tql.plugin.adapters.XContentSession]  
! at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:655)  
! at org.elasticsearch.common.io.stream.StreamOutput.lambda$static$11(StreamOutput.java:570)  
! at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:653)  
! at org.elasticsearch.common.io.stream.StreamOutput.writeMap(StreamOutput.java:443)  
! at org.elasticsearch.script.Script.writeTo(Script.java:566)  
! at org.elasticsearch.search.builder.SearchSourceBuilder$ScriptField.writeTo(SearchSourceBuilder.java:1346)  
! at org.elasticsearch.common.io.stream.StreamOutput.writeList(StreamOutput.java:915)  
! at org.elasticsearch.search.builder.SearchSourceBuilder.writeTo(SearchSourceBuilder.java:249)  
! at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalWriteable(StreamOutput.java:732)  
! at org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:361)  
! at org.elasticsearch.transport.TcpTransport.buildMessage(TcpTransport.java:1210)  
! at org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:1062)  
! at org.elasticsearch.transport.TcpTransport.access$1100(TcpTransport.java:115)  
! at org.elasticsearch.transport.TcpTransport$NodeChannels.sendRequest(TcpTransport.java:438)  
! at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:569)  
! at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:502)  
! at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:490)  
! at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51)  
! at org.elasticsearch.client.transport.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:59)  
! at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:251)  
! at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)  
! at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366)  
! at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)  
! at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)  
! at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)  
! ... 14 common frames omitted

Any ideas of what we are missing? Is this change in behaviour between versions intended? Do we need to convert the param to a Map (and all submaps) or elastic search offers something? Parameters have to be objects so should be supported I guess.

Thanks!

---

<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:** [June 14, 2017, 11:45am UTC](https://discuss.elastic.co/t/script-plugin-parameters-throw-ioexception-can-not-write-type/86092/2 "2017-06-14T11:45:52Z")

</div>

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