2016-03-23 119 views
0

我創建的java程序使用下面的代碼Sqoop用java失敗

String cmd = "import --connect \"jdbc:mysql://ip:3306/test\" --username root --password root --table seekay --target-dir /seekay -m 1"; 
Sqoop.runTool(cmd.split(" ")); 

當我運行該程序從MySQL數據庫導入HDFS表執行sqoop-1.4.5,我得到異常

下方
2016-03-23 15:49:56,260 INFO [Timer-Driven Process Thread-2] org.apache.sqoop.Sqoop Running Sqoop version: 1.4.5 
2016-03-23 15:49:56,296 WARN [Timer-Driven Process Thread-2] org.apache.sqoop.tool.BaseSqoopTool Setting your password on the command-line is insecure. Consider using -P instead. 
2016-03-23 15:49:56,332 WARN [Timer-Driven Process Thread-2] org.apache.sqoop.ConnFactory $SQOOP_CONF_DIR has not been set in the environment. Cannot check for additional configuration. 
2016-03-23 15:49:56,649 ERROR [Timer-Driven Process Thread-2] o.a.sqoop.manager.oracle.OraOopUtilities Unable to determine whether debug logging should be enabled. 
java.lang.NullPointerException 
    at org.apache.sqoop.manager.oracle.OraOopUtilities.enableDebugLoggingIfRequired(OraOopUtilities.java:239) 
    at org.apache.sqoop.manager.oracle.OraOopManagerFactory.accept(OraOopManagerFactory.java:69) 
    at org.apache.sqoop.ConnFactory.getManager(ConnFactory.java:184) 
    at org.apache.sqoop.tool.BaseSqoopTool.init(BaseSqoopTool.java:247) 
    at org.apache.sqoop.tool.ImportTool.init(ImportTool.java:89) 
    at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:589) 
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143) 
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) 
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179) 
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218) 
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227) 

我在classpath中添加了所有依賴jar文件。幫我解決這個問題。

謝謝

回答

1

我有同樣的問題。在逐步調試後發現它是log4j依賴性問題。

我從springframework的排除log4j的環比SLF4J的解決方案:

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-data-jpa</artifactId> 
    <exclusions> 
     <exclusion> 
      <groupId>org.slf4j</groupId> 
      <artifactId>log4j-over-slf4j</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency>