通过java运行Sqoop导出时出错

通过java运行Sqoop导出时出错,java,sqoop,Java,Sqoop,我有一个java程序来运行export命令。在执行导出时,它尝试在本地计算机中查找导出目录,而不是Hdfs。同样的程序可以很好地用于导入。我已检查该文件是否存在于hdfs上 请帮忙 下面是我正在执行的代码: public void executeSqoopLoad() throws UnsupportedEncodingException{ SqoopOptions options = new SqoopOptions(); String driver = "oracle.jd

我有一个java程序来运行export命令。在执行导出时,它尝试在本地计算机中查找导出目录,而不是Hdfs。同样的程序可以很好地用于导入。我已检查该文件是否存在于hdfs上

请帮忙

下面是我正在执行的代码:

public void executeSqoopLoad() throws UnsupportedEncodingException{
    SqoopOptions options = new SqoopOptions();

    String driver = "oracle.jdbc.driver.OracleDriver";
    //options.setDriverClassName(driver);
    options.setUsername(“user");
    options.setPassword(“pass");
    options.setConnectString("jdbc:oracle:thin:@host:1522:rptdev");

    Configuration configuration = new Configuration(false);
    Resource configResource;
    try {
        configResource = FileUtils.getFileResource("/Users/Moiz/git/jef/hadoop/hdfs-site.xml");
        configuration.addResource(configResource.getInputStream());
        configResource = FileUtils.getFileResource("/Users/Moiz/git/jef/hadoop/core-site.xml");
        configuration.addResource(configResource.getInputStream());
        FileSystem dfs = FileSystem.get(configuration); 

        String[] uriSplit = dfs.getUri().toString().split(":");
        String newUri = uriSplit[0]+":"+uriSplit[1];
        dfs.setWorkingDirectory(new Path(newUri+"/tmp"));
        System.out.println(dfs.getWorkingDirectory());

        System.out.println("Exists = " + dfs.exists(dfs.getWorkingDirectory()));

        DateTime dt =  new DateTime();
        options.setCodeOutputDir("/tmp");
        options.setClassName("SqoopLoad_"+null+dt.getYear()+dt.getMonthOfYear()+dt.getDayOfMonth()+dt.getMillisOfDay());
        options.setVerbose(true);
        // HDFS options
        options.setExportDir(dfs.getWorkingDirectory()+"/TestDirectory");

        System.out.println("Exists = " + dfs.exists(new Path(options.getExportDir())));
        options.setInputFieldsTerminatedBy('\u0005');
        options.setTableName(“SCHEMA.TEST_SQP");
        options.setNumMappers(1);
        options.setDirectMode(true);
        System.setProperty(Sqoop.SQOOP_RETHROW_PROPERTY, "rethrow");

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    int ret = 100;
    try{
        ret = new ExportTool().run(options);
    }catch (Exception e) {
        System.out.println("Debug");
        e.printStackTrace();
    }
    System.out.println("return code "+ ret);
}
java.lang.RuntimeException:java.io.FileNotFoundException:File /tmp/TestDirectory/part-m-00000不存在


我让它工作了。必须通过maven重新导入sqoop JAR