Return-Path: X-Original-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 25B74D6E7 for ; Tue, 18 Dec 2012 16:19:33 +0000 (UTC) Received: (qmail 32693 invoked by uid 500); 18 Dec 2012 16:19:28 -0000 Delivered-To: apmail-hadoop-mapreduce-user-archive@hadoop.apache.org Received: (qmail 32501 invoked by uid 500); 18 Dec 2012 16:19:26 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 32488 invoked by uid 99); 18 Dec 2012 16:19:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 16:19:26 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul.van.hoven@googlemail.com designates 74.125.83.51 as permitted sender) Received: from [74.125.83.51] (HELO mail-ee0-f51.google.com) (74.125.83.51) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Dec 2012 16:19:18 +0000 Received: by mail-ee0-f51.google.com with SMTP id d4so447774eek.10 for ; Tue, 18 Dec 2012 08:18:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=nO60tMV1Yqe6OFVDMF0P7WdnQnsjKfUQaM49958/8so=; b=uUNvr61kwpHpgAey2mNsTIv0ahCPEDMpL1UlAM9dAiVp8W/04lFHXo7LwHNofRAHJm jkEgL3NUVHtLBIoF+yPP/muHh/udz7ZEh2/Wqh/kqjhit1JRH5U+3oq9NppsIPDGqaS0 41Rf7NwRpIePpPA7enTZqnMrRtRt6mPdnmtXNbh/gaaPGJuG8Qp9MyvdVC9s7elGhwkD XIQeFwaswyAtZiZNhP6UWuG9QW0lSMD6ZHE++0SQav2jOp83/0AfCdTzkNWcSovTsi79 N4E8ZDiykvgFfHlzZv83ZNOlVQlaN1rO8ltgrqWuA5wvr8boS21kJOXmLTGrHI/LUjd7 PLyw== MIME-Version: 1.0 Received: by 10.14.221.5 with SMTP id q5mr6791064eep.33.1355847538246; Tue, 18 Dec 2012 08:18:58 -0800 (PST) Received: by 10.223.157.138 with HTTP; Tue, 18 Dec 2012 08:18:58 -0800 (PST) Date: Tue, 18 Dec 2012 17:18:58 +0100 Message-ID: Subject: Job does not finish due to java.lang.ClassCastException: class java.util.Date From: Paul van Hoven To: user@hadoop.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi, I wrote a small java program for processing some log files (line after line separated by newline). I'm using ecm on amazon to perform my job. I wrote the following code: public static class Map extends Mapper { private LineParser lineParser = new LineParser(); public void map( LongWritable key, Text value, Context context ) throws IOException, InterruptedException { Click click = lineParser.parseClick( value.toString() ); if( click != null ) { context.write( click.timestamp, click ); return; } Conversion conversion = lineParser.parseConversion( value.toString() ); if( conversion != null ) { context.write( conversion.timestamp, conversion ); return; } } } public static class Reduce extends Reducer { public void reduce( Date key, Iterable values, Context context) throws IOException, InterruptedException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); for( Object obj : values ) { if( obj.getClass().getName().equals("myHadoopProject.Click") ) context.write( new Text( sdf.format( key ) ), new Text( ((Click) obj).toHadoopString() ) ); else context.write( new Text( sdf.format( key ) ), new Text( ((Click) obj).toHadoopString() ) ); } } } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = new Job(conf, "MyHadoopJob"); job.setJarByClass(MyHadoopClass.class); job.setOutputKeyClass(Date.class); job.setOutputValueClass(Object.class); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setInputFormatClass(TextInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); FileInputFormat.addInputPath( job, new Path( args[0] ) ); FileOutputFormat.setOutputPath( job, new Path( args[1] ) ); job.waitForCompletion(true); } Unfortunately I get the following Exception and the job fails: java.lang.ClassCastException: class java.util.Date at java.lang.Class.asSubclass(Class.java:3018) at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:786) at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.(MapTask.java:975) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.(MapTask.java:681) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:763) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:375) at org.apache.hadoop.mapred.Child$4.run(Child.java:255) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:396) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1132) at org.apache.hadoop.mapred.Child.main(Child.java:249) What is wrong with my code?