Hadoop2.2 simple upload file, the Web environment to start the error, ask the big God

Source: Internet
Author: User

string home = "hdfs://192.168.0.212:8020/"; 
String src = "/root/desktop/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");

This code is executed in the main method without problems, but putting this piece of code into the servlet's Doget method starts with a problem, and
should be http://www.hadoopor.com/ Thread-1724-1-1.html is a problem, according to the bottom of this article, add the three jar package to Classpath can not solve, or throw an exception,
The main exception is as follows

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 has been introduced, using the same jar package as in the Main method
Have org/apache/hadoop/conf/configuration
All are hadoop2.2.0 in the jar package, the main method directly run successfully, the jar package should not have any problems, mainly Web projects, the project started when the error, not clear why,
Has confirmed Hadoop-common-2.2.0.jar
Org/apache/hadoop/conf/configuration, the project can also introduce Org.apache.hadoop.conf.Configuration,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.