java.lang.NoClassDefFoundError: com/mongodb/DBObject

JIRA | Nitin | 3 years ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to Rafael Fischer Viola and rafael . Or join the community to write better ones.
  1. 0

    I am trying to query data from mongo via hadoop and running in to the issue steps add jar mongo-2.10.1.jar; add jar mongo-hadoop-core_cdh4.3.0-1.2.0-rc1.jar; add jar mongo-hadoop-hive_cdh4.3.0-1.2.0-rc1.jar; create table influtive(id INT, item string, qty int) STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler' WITH SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id"}') TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/test.products'); select * from influtive; Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/DBObject at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitterByClass(MongoSplitterFactory.java:45) at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitter(MongoSplitterFactory.java:109) at com.mongodb.hadoop.hive.input.HiveMongoInputFormat.getSplits(HiveMongoInputFormat.java:64) at com.mongodb.hadoop.hive.input.HiveMongoInputFormat.getSplits(HiveMongoInputFormat.java:44) at org.apache.hadoop.hive.ql.exec.FetchOperator.getRecordReader(FetchOperator.java:383) at org.apache.hadoop.hive.ql.exec.FetchOperator.getNextRow(FetchOperator.java:511) at org.apache.hadoop.hive.ql.exec.FetchOperator.pushRow(FetchOperator.java:491) at org.apache.hadoop.hive.ql.exec.FetchTask.fetch(FetchTask.java:136) at org.apache.hadoop.hive.ql.Driver.getResults(Driver.java:1412) at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:271) at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:216) at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:756) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.RunJar.main(RunJar.java:160) Caused by: java.lang.ClassNotFoundException: com.mongodb.DBObject at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 19 more

    JIRA | 3 years ago | Nitin
    java.lang.NoClassDefFoundError: com/mongodb/DBObject
  2. 0

    I am trying to query data from mongo via hadoop and running in to the issue steps add jar mongo-2.10.1.jar; add jar mongo-hadoop-core_cdh4.3.0-1.2.0-rc1.jar; add jar mongo-hadoop-hive_cdh4.3.0-1.2.0-rc1.jar; create table influtive(id INT, item string, qty int) STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler' WITH SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id"}') TBLPROPERTIES('mongo.uri'='mongodb://localhost:27017/test.products'); select * from influtive; Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/DBObject at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitterByClass(MongoSplitterFactory.java:45) at com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitter(MongoSplitterFactory.java:109) at com.mongodb.hadoop.hive.input.HiveMongoInputFormat.getSplits(HiveMongoInputFormat.java:64) at com.mongodb.hadoop.hive.input.HiveMongoInputFormat.getSplits(HiveMongoInputFormat.java:44) at org.apache.hadoop.hive.ql.exec.FetchOperator.getRecordReader(FetchOperator.java:383) at org.apache.hadoop.hive.ql.exec.FetchOperator.getNextRow(FetchOperator.java:511) at org.apache.hadoop.hive.ql.exec.FetchOperator.pushRow(FetchOperator.java:491) at org.apache.hadoop.hive.ql.exec.FetchTask.fetch(FetchTask.java:136) at org.apache.hadoop.hive.ql.Driver.getResults(Driver.java:1412) at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:271) at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:216) at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:756) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.hadoop.util.RunJar.main(RunJar.java:160) Caused by: java.lang.ClassNotFoundException: com.mongodb.DBObject at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 19 more

    JIRA | 3 years ago | Nitin
    java.lang.NoClassDefFoundError: com/mongodb/DBObject
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0
    samebug tip
    A few things cause this exception: 1) Check if you have all jars and if they're in the correct path when running. 2) Your classpath might be broken, you can define it in the command line with "java -cp yourClassPath" or at your IDE if you're using one.
  5. 0
    samebug tip
    If you're using Hibernate, this indicates you're missing FasterXML Classmate dependency, which you can add with the following: <groupId>com.fasterxml</groupId> <artifactId>classmate</artifactId> <version>1.0</version>
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassNotFoundException

    com.mongodb.DBObject

    at java.net.URLClassLoader$1.run()
  2. Java RT
    ClassLoader.loadClass
    1. java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    2. java.security.AccessController.doPrivileged(Native Method)
    3. java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    4. java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    5. sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    6. java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    6 frames
  3. com.mongodb.hadoop
    HiveMongoInputFormat.getSplits
    1. com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitterByClass(MongoSplitterFactory.java:45)
    2. com.mongodb.hadoop.splitter.MongoSplitterFactory.getSplitter(MongoSplitterFactory.java:109)
    3. com.mongodb.hadoop.hive.input.HiveMongoInputFormat.getSplits(HiveMongoInputFormat.java:64)
    4. com.mongodb.hadoop.hive.input.HiveMongoInputFormat.getSplits(HiveMongoInputFormat.java:44)
    4 frames
  4. Hive Query Language
    Driver.getResults
    1. org.apache.hadoop.hive.ql.exec.FetchOperator.getRecordReader(FetchOperator.java:383)
    2. org.apache.hadoop.hive.ql.exec.FetchOperator.getNextRow(FetchOperator.java:511)
    3. org.apache.hadoop.hive.ql.exec.FetchOperator.pushRow(FetchOperator.java:491)
    4. org.apache.hadoop.hive.ql.exec.FetchTask.fetch(FetchTask.java:136)
    5. org.apache.hadoop.hive.ql.Driver.getResults(Driver.java:1412)
    5 frames
  5. org.apache.hadoop
    CliDriver.main
    1. org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:271)
    2. org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:216)
    3. org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413)
    4. org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:756)
    5. org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614)
    5 frames
  6. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  7. Hadoop
    RunJar.main
    1. org.apache.hadoop.util.RunJar.main(RunJar.java:160)
    1 frame