maven - NoClassDefFoundError: org/json/JSONObject - Hadoop MapReduce -
i'm trying mapreduce job using json input. imported json dependency in pom.xml , maven clean install run properly. when run jar in hadoop "noclassdeffounderror: org/json/jsonobject" error on mapper class. (i tried json java external jar, doesn't work.
this test mapper class:
package com.andrew.hadoopnba.nbajob1; import java.io.ioexception; import org.apache.hadoop.io.intwritable; import org.apache.hadoop.io.text; import org.apache.hadoop.mapreduce.mapper; import org.json.*; public class pointsrankingmapper extends mapper<object, text, text, intwritable> { public void map(object key, text value, context context) throws ioexception, interruptedexception { try { jsonobject jsn = new jsonobject(value.tostring()); system.out.println("printing json " + jsn); } catch (exception e) { // todo auto-generated catch block e.printstacktrace(); } } }
and maven dependency:
<dependency> <groupid>org.json</groupid> <artifactid>json</artifactid> <version>20140107</version> </dependency>
any ideas?
you can use jackson process json.
<repositories> <repository> <id>codehaus</id> <url>http://repository.codehaus.org/org/codehaus</url> </repository> </repositories> <dependencies> <dependency> <groupid>org.codehaus.jackson</groupid> <artifactid>jackson-mapper-asl</artifactid> <version>1.8.5</version> </dependency> </dependencies>
or google's gson
<dependency> <groupid>com.google.code.gson</groupid> <artifactid>gson</artifactid> <version>1.7.1</version> </dependency>
Comments
Post a Comment