Hadoop2.2簡單上傳檔案,web環境下啟動報錯,求大神

來源:互聯網
上載者:User

標籤:http   java   os   檔案   io   art   

String home = "hdfs://192.168.0.212:8020/";
String src = "/root/案頭/111.jpg";
String dst = "/6.jpg";
InputStream in = new BufferedInputStream(new FileInputStream(src));
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(home), conf);
OutputStream out = fs.create(new Path(home+dst));
IOUtils.copyBytes(in, out, 4096, true);
System.out.println("success");

這段代碼在main方法中執行沒有問題,順利通過,但是將這段代碼放到Servlet的doGet方法中啟動時出問題,
應該跟http://www.hadoopor.com/thread-1724-1-1.html是一個問題,根據這篇文章最下面的方法,將那三個jar包加到CLASSPATH解決不了,還是拋異常,
主要異常如下

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/test]]

Caused by: java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration




PS:hadoop-common-2.2.0.jar已經引入了,用的跟在main方法是一樣的jar包
有org/apache/hadoop/conf/Configuration
全部都是hadoop2.2.0中的jar包,main方法直接運行成功,jar包應該不會有什麼問題,主要是web項目,項目啟動的時候報錯,不清楚原因,
已經確認hadoop-common-2.2.0.jar
中存在org/apache/hadoop/conf/Configuration,項目中也能引入org.apache.hadoop.conf.Configuration,

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.