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,