Failed query execution: java.lang.NoClassDefFoundError: com/mongodb/util/JSON

773 views
Skip to first unread message

Mariana Gavrilescu

unread,
Jul 10, 2014, 7:55:02 AM7/10/14
to mongod...@googlegroups.com

I have installed the mongo-hadoop connector specifying the hadoop version I use, at the building time
./gradlew jar -Phadoop_version=2.2
Using Hue I have copied the jars on HDFS:
mongo-hadoop-core-1.4.0-SNAPSHOT.jar
mongo-hadoop-hive-1.4.0-SNAPSHOT.jar
mongo-hadoop.jar

In the Hive editor I added the already enumerated jar and I tried to ran the following query:
DROP TABLE IF EXISTS users;
CREATE TABLE users
  id INT,
  name STRING,
  age INT
  
)
STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler'
WITH SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id","name":"name","age":"age"}')
TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/test.users');

The "users" collection exists in MongoDB.
I get the following exception:

14/07/10 11:42:55 ERROR exec.DDLTask: java.lang.NoClassDefFoundError: com/mongodb/util/JSON
	at com.mongodb.hadoop.hive.BSONSerDe.initialize(BSONSerDe.java:107)
	at org.apache.hadoop.hive.metastore.MetaStoreUtils.getDeserializer(MetaStoreUtils.java:170)
	at org.apache.hadoop.hive.ql.metadata.Table.getDeserializerFromMetaStore(Table.java:272)
	at org.apache.hadoop.hive.ql.metadata.Table.getDeserializer(Table.java:265)
	at org.apache.hadoop.hive.ql.metadata.Table.getCols(Table.java:597)
	at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:578)
	at org.apache.hadoop.hive.ql.exec.DDLTask.createTable(DDLTask.java:3697)
	at org.apache.hadoop.hive.ql.exec.DDLTask.execute(DDLTask.java:253)
	at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:151)
	at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:65)
	at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1485)
	at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1263)
	at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1091)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:931)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:926)
	at org.apache.hive.service.cli.operation.SQLOperation.runInternal(SQLOperation.java:144)
	at org.apache.hive.service.cli.operation.SQLOperation.access$100(SQLOperation.java:64)
	at org.apache.hive.service.cli.operation.SQLOperation$1.run(SQLOperation.java:177)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.mongodb.util.JSON
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 23 more

Will Berkeley

unread,
Jul 11, 2014, 12:48:54 PM7/11/14
to mongod...@googlegroups.com
Hi. The error indicates that the com.mongodb.util.JSON class could not be loaded. Have you copied the mongo-java-driver jar so it's available on Hadoop as well? See the installation instructions for mongo-hadoop.

-Will

hei yingzi

unread,
Jun 17, 2018, 6:47:30 PM6/17/18
to mongodb-user
I use mongodb in hive, and add jar to calling mongo-java-driver and sees the same execution

在 2014年7月12日星期六 UTC+8上午12:48:54,Will Berkeley写道:

Wan Bachtiar

unread,
Jul 6, 2018, 2:31:36 AM7/6/18
to mongodb-user

I use mongodb in hive, and add jar to calling mongo-java-driver and sees the same execution

Hi YingZi,

Although you may see a similar error, it may be entirely different reason causing it.

Please open a new discussion thread along with the following relevant information:

  • MongoDB version
  • mongo-hadoop connector version
  • Apache Hive version
  • The jars and their respective versions
  • The commands that you executed
  • Stack trace or error messages

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages