hadoop jar提交错误java.lang.instantiationexception

7cjasjjr  于 2021-06-04  发布在  Hadoop
关注(0)|答案(1)|浏览(413)

我正试图在hadoop文件系统上运行jar,但遇到这个异常,请参见图片

如果我从eclipse上运行代码,那么它将成功运行。
这是我的跑步课

public class ReadCassandra extends Configured implements Tool{

        public static void main(String args[]){
            try{
                /*ToolRunner.run(new Configuration(),new ReadCassandra(), args);
                System.exit(0);*/

                String keyspace ="Read_log";
                String clg ="readValidPost";
                String rowkey="117761667160131";
                List<ByteBuffer> cn = new ArrayList<ByteBuffer>();
                List<String> cl = new ArrayList<String>();
                cl.addAll(MyHector.getColumn(rowkey));
                for (String string : cl) {
                    ByteBuffer bf = ByteBufferUtil.bytes(string);
                    cn.add(bf);
                }
                Configuration conf = new Configuration();
                Job job = new Job(conf,"MEJfsd");
                //job.setJarByClass(ReadCassandra.class);

                job.setInputFormatClass(AbstractColumnFamilyInputFormat.class);
                job.setOutputFormatClass(TextOutputFormat.class);

                job.setOutputKeyClass(Text.class);
                job.setOutputValueClass(Text.class);

                job.setMapperClass(MyMapper.class);
                job.setReducerClass(MyReducer.class);

                ConfigHelper.setInputRpcPort(job.getConfiguration(), "9160");
                ConfigHelper.setInputInitialAddress(job.getConfiguration(), "127.0.0.1");
                ConfigHelper.setInputPartitioner(job.getConfiguration(), "org.apache.cassandra.dht.Murmur3Partitioner");
                ConfigHelper.setInputColumnFamily(job.getConfiguration(), keyspace, clg);

                SlicePredicate predicate = new SlicePredicate().setColumn_names(cn);
                ConfigHelper.setInputSlicePredicate(job.getConfiguration(), predicate);

                FileSystem.get(job.getConfiguration()).delete(new Path("Output"), true);
                FileOutputFormat.setOutputPath(job, new Path("Output"));
                job.waitForCompletion(true);

            }catch(Exception e){
                e.printStackTrace();
            }
        }

        public int run(String[] arg0) throws Exception {

            return (1);
        }

    }

我在用命令运行

hadoop jar /home/winoria/Documents/JarFiles/ReadCas.jar ReadCassandra
frebpwbc

frebpwbc1#

您正在将输入格式类设置为抽象类:

job.setInputFormatClass(AbstractColumnFamilyInputFormat.class);

你需要把它设置成可以示例化的东西。但我不知道cassandra hadoop集成以及在您的案例中有什么意义。只要确保它不是一个抽象类。

相关问题