# Failed with exception java.io.IOException:java.lang.ClassCastException: org.elasticsearch.hadoop.mr.WritableArrayWritable cannot be cast to org.apache.hadoop.io.Text

**URL:** <https://discuss.elastic.co/t/failed-with-exception-java-io-ioexception-java-lang-classcastexception-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-text/43661>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [March 7, 2016, 2:30pm UTC](https://discuss.elastic.co/t/failed-with-exception-java-io-ioexception-java-lang-classcastexception-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-text/43661 "2016-03-07T14:30:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohan\_p](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@mohan\_p](https://discuss.elastic.co/u/mohan_p)\
**Post date:** [March 7, 2016, 2:30pm UTC](https://discuss.elastic.co/t/failed-with-exception-java-io-ioexception-java-lang-classcastexception-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-text/43661/1 "2016-03-07T14:30:20Z")

</div>

Continuing the discussion from [ElasticSearch 2.1.2 JAR for Hadoop Integration is not working](https://discuss.elastic.co/t/elasticsearch-2-1-2-jar-for-hadoop-integration-is-not-working/37031):

CREATE EXTERNAL TABLE TestTable(key STRING,msgtype STRING,app\_log\_ts STRING) STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'  
TBLPROPERTIES('es.resource' = 'logstash-\*/log', 'es.nodes' = 'es.host', 'es.port' = '9200','es.mapping.names' = 'key:CLIENT\_ORDER\_ID,msgtype:MESSAGE\_TYPE,app\_log\_ts:APP\_TIME');

Whilke executing select I see exception :  
select \* from TestTable;  
Failed with exception java.io.IOException:java.lang.ClassCastException: org.elasticsearch.hadoop.mr.WritableArrayWritable cannot be cast to org.apache.hadoop.io.Text

NOTE : Its Prints first few the rows, then throws the exception and exit.  
I See ES has text for the all the field.

jar :   
elasticsearch-hadoop-2.2.0-m1.jar

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [March 8, 2016, 7:48am UTC](https://discuss.elastic.co/t/failed-with-exception-java-io-ioexception-java-lang-classcastexception-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-text/43661/2 "2016-03-08T07:48:23Z")

</div>

1. use the latest GA jar (currently 2.2.0) not a milestone.
2. there's a type mismatch in your mapping, namely a field is mapped as an array while your hive mapping wants a single-valued String. More about it [here](https://www.elastic.co/guide/en/elasticsearch/hadoop/master/mapping.html#mapping-multi-values).

---

<div class="post-metadata">

**Author:** ![mohan\_p](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@mohan\_p](https://discuss.elastic.co/u/mohan_p)\
**Post date:** [March 11, 2016, 9:54am UTC](https://discuss.elastic.co/t/failed-with-exception-java-io-ioexception-java-lang-classcastexception-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-text/43661/3 "2016-03-11T09:54:56Z")

</div>

Hi Costin,  
Attribute "es.read.field.as.array.exclude" helped to resolve.  
Thanks for your quick response !!

---

<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 6, 2017, 1:25pm UTC](https://discuss.elastic.co/t/failed-with-exception-java-io-ioexception-java-lang-classcastexception-org-elasticsearch-hadoop-mr-writablearraywritable-cannot-be-cast-to-org-apache-hadoop-io-text/43661/4 "2017-07-06T13:25:49Z")

</div>


