Skip to main content
sagittarian
Gold ⭐️
December 18, 2019
Solved

FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

Hi Everyone, 

i am trying to create Hive table with data from mongodb. 

I have installed mongodb in cloudera quickstart.  loaded json data. sample:

 

{
"_id" : ObjectId("59a47286cfa9a3a73e51e749"),
"theaterId" : 1034,
"location" : {
"address" : {
"street1" : "3404 W 13th St",
"city" : "Grand Island",
"state" : "NE",
"zipcode" : "68803"
},
"geo" : {
"type" : "Point",
"coordinates" : [
-98.382164,
40.933624
]
}
}
}

 

 i have create Hive table as below 

 

CREATE EXTERNAL TABLE IF NOT EXISTS THEATER 
(
id STRING,
theaterId INT,
loc STRUCT<address:STRUCT<street1:STRING,city:STRING,city:STRING,city:STRING,street2:STRING>,
geo:STRUCT<type:STRING,coordinates:ARRAY<DOUBLE>>
>
)
STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler'
WITH SERDEPROPERTIES ('mongo.columns.mapping'='{
"id":"_id",
"theaterId":"theaterId",
"loc":"location"
}')
TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/movie_flix.theater');

when i run simple select i am able to run the application successfully. 

Screen Shot 2019-12-18 at 4.53.25 PM.png

 

but when i run select loc.address FROM theater; 

i am getting below error

FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

 

Did anyone face the same issue?

 

Thanks

EricL
EricLAnswer
Platinum ⭐️⭐️
December 19, 2019
@sagittarian ,

Thanks for sharing the finding and solution. Yes, the error message means that the JDBC driver JAR files were missing. So adding them can resolve the issue.

Cheers
Eric

5 replies

EricL
Platinum ⭐️⭐️
Platinum ⭐️⭐️
December 19, 2019
@sagittarian ,

Can you please share the full stacktrace of the error? Both from HS2 log and yarn application logs?

Thanks
Eric
Translate
sagittarian
Gold ⭐️
December 19, 2019

@EricL 

Thanks for responding, i was able to resolve this error by placing .jar files in /usr/lib/hadoop-yarn path and restarting the cluster.

 

1. bson-3.12.0.jar

2. mongodb-driver-3.12.0.jar

3. mongodb-driver-core-3.12.0.jar

4. mongo-hadoop-core-2.0.2.jar

5. mongo-hadoop-hive-2.0.2.jar

 

Thanks

Translate
newbieone
Silver ⭐️⭐️⭐️
July 21, 2022

Hi @EricL,

 

If we are using company laptop and not allowed to place these files, is there any other solutions?

Thanks.

Translate